Functions

ut_std_string.cpp File Reference

#include <string.h>
#include "ut_assert.h"
#include "ut_std_string.h"
#include "ut_string.h"
#include "ut_debugmsg.h"
#include "ut_iconv.h"
#include <iostream>
#include <sstream>
#include <list>

Functions

std::string UT_escapeXML (const std::string &s)
 replacement for UT_UTF8String::escapeXML escapes '<', '>', '"' and '&' in the current string
std::string UT_decodeXML (const std::string &s)
 Unescape (decode) XML.
std::string & UT_std_string_vprintf (std::string &inStr, const char *format, va_list args1)
std::string UT_std_string_sprintf (const char *inFormat,...)
std::string UT_std_string_unicode (const UT_UCS4Char *unicode, UT_uint32 len)
 Create a string form a Unicode stream.
std::string UT_std_stringFromEncoding (const char *bytes, const char *encoding)
 Returns a std::string (UTF-8) converted from an encoding.
bool ends_with (const std::string &s, const std::string &ending)
bool starts_with (const std::string &s, const std::string &starting)
 true if fullstring starts with exactly prefix.
std::string replace_all (const std::string &s, char oldc, char newc)
std::string replace_all (const std::string &s, const std::string &olds, const std::string &news)
std::string & UT_tolower (std::string &s)
 convert to lower case in-place.
std::string UT_XML_cloneNoAmpersands (const std::string &src)
std::vector< std::string > UT_simpleSplit (const std::string &str, char separator)
std::string UT_ellipsisPath (const std::string &path, size_t maxlen, size_t cut)
 Shorten a path with ellispis of over maxlen.
std::string UT_std_string_getPropVal (const std::string &sPropertyString, const std::string &sProp)
void UT_std_string_addPropertyString (std::string &sPropertyString, const std::string &sNewProp)
void UT_std_string_setProperty (std::string &sPropertyString, const std::string &sProp, const std::string &sVal)
void UT_std_string_removeProperty (std::string &sPropertyString, const std::string &sProp)
const std::string StreamToString (std::istream &iss)
std::string toTimeString (time_t TT)
time_t toTime (struct tm *tm)
time_t parseTimeString (const std::string &stddatestr)

Function Documentation

bool ends_with ( const std::string &  s,
const std::string &  ending 
)
time_t parseTimeString ( const std::string &  stddatestr  ) 
std::string replace_all ( const std::string &  s,
char  oldc,
char  newc 
)
std::string replace_all ( const std::string &  s,
const std::string &  olds,
const std::string &  news 
)
bool starts_with ( const std::string &  s,
const std::string &  starting 
)
const std::string StreamToString ( std::istream &  iss  ) 
time_t toTime ( struct tm *  tm  ) 

Referenced by parseTimeString().

std::string toTimeString ( time_t  TT  ) 
std::string UT_decodeXML ( const std::string &   ) 

Unescape (decode) XML.

Reverse of UT_escapeXML

Referenced by PP_cloneAndDecodeAttributes(), and TFTEST_MAIN().

std::string UT_ellipsisPath ( const std::string &  path,
size_t  maxlen,
size_t  cut 
)

Shorten a path with ellispis of over maxlen.

Then keep the last cut chars

References s.

Referenced by XAP_Dialog_History::getHeaderValue(), XAP_Dialog_DocComparison::getPath1(), XAP_Dialog_DocComparison::getPath2(), and TFTEST_MAIN().

std::string UT_escapeXML ( const std::string &  s  ) 
std::vector<std::string> UT_simpleSplit ( const std::string &  str,
char  separator 
)

simplesplit splits the referring string along the character 'separator', removing the separator character, and placing the resulting strings in a vector.

Referenced by AbiTest_invoke(), EV_Menu::addMenuItem(), and TFTEST_MAIN().

void UT_std_string_addPropertyString ( std::string &  sPropertyString,
const std::string &  sNewProp 
)

Assuming a string of standard abiword properties eg. "fred:nerk; table-width:1.0in; table-height:10.in" Add aother propety string, updating previously defined properties with values in the new string.

References UT_std_string_setProperty().

Referenced by ie_imp_cell::addPropString(), FV_View::cmdInsertEmbed(), FV_View::cmdUpdateEmbed(), TFTEST_MAIN(), and AP_Dialog_Styles::updateCurrentStyle().

std::string UT_std_string_getPropVal ( const std::string &  sPropertyString,
const std::string &  sProp 
)
void UT_std_string_removeProperty ( std::string &  sPropertyString,
const std::string &  sProp 
)

Assuming a string of standard abiword properties eg. "fred:nerk; table-width:1.0in; table-height:10.in" Remove the property sProp and it's value from the string of properties.

Referenced by IE_Imp_StarOffice::_loadFile(), IE_Imp_RTF::HandleAbiEmbed(), IE_Imp_RTF::HandleAbiMathml(), IE_Imp_RTF::HandleAbiTable(), TFTEST_MAIN(), and UT_std_string_setProperty().

void UT_std_string_setProperty ( std::string &  sPropertyString,
const std::string &  sProp,
const std::string &  sVal 
)
std::string UT_std_string_sprintf ( const char *  inFormat,
  ... 
)

References UT_std_string_vprintf().

Referenced by IE_Imp_RTF::_appendHdrFtr(), IE_Imp_MsWord_97::_beginPara(), PD_Document::_buildAuthorProps(), ODi_Style_PageLayout::_buildSectionPropsString(), FV_View::_changeCellAttach(), FV_View::_changeCellParams(), FV_View::_changeCellTo(), _convertBorderThickness(), IE_Imp_OPML::_createBullet(), fl_BlockLayout::_createListLabel(), ODi_TextContent_ListenerState::_defineAbiTOCHeadingStyles(), ODi_Frame_ListenerState::_drawObject(), s_RTF_ListenerWriteDoc::_export_AbiWord_Cell_props(), s_RTF_ListenerWriteDoc::_fillTableProps(), GR_CairoGraphics::_findFont(), IE_Imp_RTF::_formRevisionAttr(), AP_Dialog_FormatTable::_getToggleButtonStatus(), AP_Dialog_FormatFrame::_getToggleButtonStatus(), AP_Dialog_Border_Shading::_getToggleButtonStatus(), s_KWord_1_Listener::_handleDataItems(), IE_Imp_MsWord_97::_handleImage(), IE_Imp_MsWord_97::_handleNotes(), IE_Imp_MsWord_97::_handleNotesText(), ODi_TextContent_ListenerState::_insertAnnotation(), FV_View::_insertCellAt(), IE_Imp_MsWord_97::_insertEndnote(), IE_Imp_MsWord_97::_insertFootnote(), IE_Imp_MsWord_97::_insertHeaderSection(), IE_Imp_StarOffice::_loadFile(), OpenWriter_ContentStream_Listener::_openCell(), IE_Exp_RTF::_output_LevelText(), ODi_Style_Style::_parse_style_paragraphProperties(), ODi_Style_Style::_parse_style_sectionProperties(), ODi_Style_Style::_parse_style_textProperties(), ODi_Table_ListenerState::_parseCellStart(), AP_Dialog_Styles::_populateAbiPreview(), FV_View::_restoreCellParams(), AD_Document::_restoreVersion(), ODi_Numbered_ListLevelStyle::_setAbiListType(), fp_MathRun::_updatePropValuesIfNeeded(), fp_EmbedRun::_updatePropValuesIfNeeded(), IE_Imp_T602::_write_fh(), IE_Imp_T602::_writePP(), IE_Imp_T602::_writeSP(), s_RTF_ListenerWriteDoc::_writeSPNumProp(), abi_widget_set_text_color(), PD_Document::addAuthorAttributeIfBlank(), IE_Imp_RTF::addFrame(), OXML_List::addToPT(), OXML_Element_Math::addToPT(), OXML_Element_Cell::addToPT(), AP_Dialog_Border_Shading::AP_Dialog_Border_Shading(), ap_sbf_PageInfo::ap_sbf_PageInfo(), AP_Dialog_Lists::Apply(), IE_Imp_Psion::applyPageAttributes(), IE_Imp_RTF::ApplyParagraphAttributes(), IE_Imp_RTF::ApplySectionAttributes(), PD_Document::areDocumentStylesheetsEqual(), AP_Dialog_FormatFrame::askForGraphicPathName(), RTF_msword97_level::buildAbiListProperties(), ODi_Style_Style::buildAbiPropsAttrString(), IE_Imp_RTF::buildAllProps(), IE_Imp_RTF::buildCharacterProps(), buildTemplateList(), fp_FieldPageReferenceRun::calculateValue(), IE_Imp_RTF::closePastedTableIfNeeded(), FV_View::cmdDeleteCol(), FV_View::cmdDeleteRow(), FV_View::cmdInsertCol(), FV_View::cmdInsertRow(), FV_View::cmdInsertTable(), FV_View::cmdSplitCells(), FV_View::cmdTextToTable(), IE_Imp_DocBook::createImage(), GR_CairoRasterImage::createImageSegment(), ODi_Style_PageLayout::definePageSizeTag(), Defun(), Defun1(), Defun_EV_GetToolbarItemState_Fn(), IE_Imp_RTF::EndAnnotation(), ODi_TextContent_ListenerState::endElement(), ODi_Frame_ListenerState::endElement(), IE_Imp_XHTML::endElement(), ODe_ManifestWriter::ensureDirectoryManifest(), IE_Exp_EPUB::EPUB2_writeNavigation(), IE_Exp_EPUB::EPUB2_writeStructure(), IE_Exp_EPUB::EPUB3_writeNavigation(), AP_UnixDialog_Border_Shading::event_BorderThicknessChanged(), AP_UnixDialog_Border_Shading::event_ShadingOffsetChanged(), AP_Dialog_RDFQuery::executeQuery(), GR_Graphics::findFont(), fl_BlockLayout::getListAttributesVector(), GR_Win32Font::GR_Win32Font(), IE_Imp_RTF::HandleAbiCell(), IE_Imp_RTF::HandleAbiEndTable(), IE_Imp_RTF::HandleAbiTable(), IE_Imp_RTF::HandleAnnotation(), IE_Imp_RTF::HandleNote(), IE_Imp_RTF::HandleNoteReference(), IE_Exp_HTML_StyleTree::IE_Exp_HTML_StyleTree(), FV_View::insertAnnotation(), FV_View::insertFootnote(), FV_View::insertHeaderFooter(), IE_Imp_RTF::InsertImage(), localizeButtonMarkup(), localizeLabelMarkup(), makeColor(), UT_VersionInfo::makeVersString(), FV_VisualInlineImage::mouseCopy(), FV_VisualInlineImage::mouseRelease(), ap_sbf_PageInfo::notify(), ODc_reorderDate(), ODi_Numbered_ListLevelStyle::ODi_Numbered_ListLevelStyle(), IE_Imp_WordPerfect::openEndnote(), IE_Imp_WordPerfect::openFootnote(), OO_PageStyle::parse(), IE_Imp_MSWrite::read_pic(), GR_PangoFont::reloadFont(), fl_BlockLayout::remItemFromList(), XAP_UnixDialog_MessageBox::runModal(), s_AbiWord_1_Listener::s_AbiWord_1_Listener(), s_append_font_size(), s_doInsertTableDlg(), s_props_append(), FV_View::setAnnotationText(), AP_Dialog_FormatFrame::setBGColor(), AP_Dialog_FormatTable::setBorderColor(), AP_Dialog_Border_Shading::setBorderColor(), AP_Dialog_FormatFrame::setBorderColorBottom(), AP_Dialog_FormatFrame::setBorderColorLeft(), AP_Dialog_FormatFrame::setBorderColorRight(), AP_Dialog_FormatFrame::setBorderColorTop(), AP_Dialog_FormatFrame::setBorderLineStyleBottom(), AP_Dialog_FormatFrame::setBorderLineStyleLeft(), AP_Dialog_FormatFrame::setBorderLineStyleRight(), AP_Dialog_FormatFrame::setBorderLineStyleTop(), AP_Dialog_Border_Shading::setBorderThickness(), ie_imp_cell::setBot(), AP_Dialog_FormatTable::setCurCellProps(), AP_Dialog_FormatFrame::setCurFrameProps(), XAP_UnixWidget::setLabelCStr(), setLabelMarkup(), ie_imp_cell::setLeft(), ie_imp_cell::setRight(), AP_Dialog_Border_Shading::setShadingColor(), AP_Win32Dialog_Stylist::setStyleInGUI(), ie_imp_cell::setTop(), XAP_UnixWidget::setValueFloat(), XAP_UnixWidget::setValueInt(), IE_Imp_RTF::StartAnnotation(), ODi_TextContent_ListenerState::startElement(), ODi_Bullet_ListLevelStyle::startElement(), IE_Imp_XSL_FO::startElement(), IE_Imp_XHTML::startElement(), IE_Imp_DocBook::startElement(), AP_Dialog_RDFEditor::statusIsTripleCount(), streamRead(), IE_Imp_TableHelper::tdStart(), AP_Dialog_FormatTable::toggleLineType(), AP_Dialog_FormatFrame::toggleLineType(), AP_Dialog_Border_Shading::toggleLineType(), IE_Imp_RTF::TranslateKeywordID(), AP_Dialog_FormatFootnotes::updateDocWithValues(), ODe_ManifestWriter::writeManifest(), OO_ManifestWriter::writeManifest(), ODe_MetaDataWriter::writeMetaData(), OO_MetaDataWriter::writeMetaData(), and OO_PicturesWriter::writePictures().

std::string UT_std_string_unicode ( const UT_UCS4Char unicode,
UT_uint32  len 
)

Create a string form a Unicode stream.

Will be UTF8 encoded.

Parameters:
unicode the Unicode UCS4 string. Can't be NULL
len the length of the Unicode UCS4 string. Must match the length.
Returns:
the std::string. Empty string if an invalid parameter or error.

References abicollab::service::error(), gchar, s, and UT_DEBUGMSG.

Referenced by AbiTest_invoke(), and TFTEST_MAIN().

std::string& UT_std_string_vprintf ( std::string &  inStr,
const char *  format,
va_list  args1 
)
std::string UT_std_stringFromEncoding ( const char *  bytes,
const char *  encoding 
)

Returns a std::string (UTF-8) converted from an encoding.

Parameters:
bytes the input bytes (not NULL)
encoding the encoding (not NULL)
Returns:
an UTF-8 enconded std::string

References FREEP, UT_ASSERT, and UT_convert().

Referenced by ap_sbf_InputMode::notify(), and AP_StatusBar::setStatusMessage().

std::string& UT_tolower ( std::string &  s  ) 

convert to lower case in-place.

Use std::tolower.

Parameters:
s the string to lower case. Mutable.
Returns:
s

Referenced by s_removeWhiteSpace(), TFTEST_MAIN(), and UT_HTML::UT_HTML().

std::string UT_XML_cloneNoAmpersands ( const std::string &  src  )