zypp::str Namespace Reference

String related utilities and Regular expressions. More...


Classes

struct  SafeBuf
 Assert free called for allocated char *. More...

Trimming whitepace.

Todo:
optimize l/r trim.


enum  Trim { NO_TRIM = 0x00, L_TRIM = 0x01, R_TRIM = 0x02, TRIM = (L_TRIM|R_TRIM) }
 To define how to trim. More...
std::string trim (const std::string &s, const Trim trim_r)
std::string ltrim (const std::string &s)
std::string rtrim (const std::string &s)

Functions

std::string form (const char *format,...) __attribute__((format(printf
 Printf style construction of std::string.
std::string strerror (int errno_r)
 Return string describing the error_r code.
std::string stripFirstWord (std::string &line, const bool ltrim_first)
static std::string _getline (std::istream &str, const Trim trim_r)
std::string getline (std::istream &str, const Trim trim_r)
std::string getline (std::istream &str, bool trim)
Case conversion.
std::string toLower (const std::string &s)
 Return lowercase version of s.
std::string toUpper (const std::string &s)
 Return uppercase version of s.
String representation of number.
Optional second argument sets the minimal string width (' ' padded).

Negative values will cause the number to be left adjusted within the string.

Default width is 0.

 numstring(42)           -> "42"
 numstring(42, 4)        -> "  42"
 numstring(42,-4)        -> "42  "


std::string numstring (char n, int w=0)
std::string numstring (unsigned char n, int w=0)
std::string numstring (short n, int w=0)
std::string numstring (unsigned short n, int w=0)
std::string numstring (int n, int w=0)
std::string numstring (unsigned n, int w=0)
std::string numstring (long n, int w=0)
std::string numstring (unsigned long n, int w=0)
std::string numstring (long long n, int w=0)
std::string numstring (unsigned long long n, int w=0)
String representation of number as hex value with leading '0x'.
Optional second argument sets the minimal string width (0 padded).

Negative values will cause the number to be left adjusted within the string. Default width is 10 (4 for char).

 hexstring(42)           -> "0x0000002a"
 hexstring(42, 4)        -> "0x2a"
 hexstring(42,-4)        -> "0x2a"
 


std::string hexstring (char n, int w=4)
std::string hexstring (unsigned char n, int w=4)
std::string hexstring (short n, int w=10)
std::string hexstring (unsigned short n, int w=10)
std::string hexstring (int n, int w=10)
std::string hexstring (unsigned n, int w=10)
std::string hexstring (long n, int w=10)
std::string hexstring (unsigned long n, int w=10)
std::string hexstring (long long n, int w=0)
std::string hexstring (unsigned long long n, int w=0)
String representation of number as octal value with leading '0'.
Optional second argument sets the minimal string width (0 padded).

Negative values will cause the number to be left adjusted within the string. Default width is 5 (4 for char).

 octstring(42)           -> "00052"
 octstring(42, 4)        -> "0052"
 octstring(42,-4)        -> "052 "
 


std::string octstring (char n, int w=4)
std::string octstring (unsigned char n, int w=4)
std::string octstring (short n, int w=5)
std::string octstring (unsigned short n, int w=5)
std::string octstring (int n, int w=5)
std::string octstring (unsigned n, int w=5)
std::string octstring (long n, int w=5)
std::string octstring (unsigned long n, int w=5)
std::string octstring (long long n, int w=0)
std::string octstring (unsigned long long n, int w=0)
template<typename _It>
_It strtonum (const std::string &str)
 String to integer type determined by template arg.
template<typename _It>
_It strtonum (const std::string &str, _It &i)
 String to integer type detemined 2nd function arg i.
Split.
template<class _OutputIterator>
unsigned split (const std::string &line_r, _OutputIterator result_r, const std::string &sepchars_r=" \t")
 Split line_r into words.
Join.
template<class _Iterator>
std::string join (_Iterator begin, _Iterator end, const std::string &sep_r=" ")
 Join strings using separator sep_r (defaults to BLANK).
template<class _Container>
std::string join (const _Container &cont_r, const std::string &sep_r=" ")
 Join strings using separator sep_r (defaults to BLANK).


Detailed Description

String related utilities and Regular expressions.

See also:
Regular expressions


Enumeration Type Documentation

enum zypp::str::Trim

To define how to trim.

Enumerator:
NO_TRIM 
L_TRIM 
R_TRIM 
TRIM 

Definition at line 292 of file String.h.


Function Documentation

std::string zypp::str::form ( const char *  format,
  ... 
)

Printf style construction of std::string.

Definition at line 31 of file String.cc.

References zypp::str::SafeBuf::_buf, and zypp::str::SafeBuf::asString().

Referenced by zypp::Edition::asString(), zypp::exception_detail::CodeLocation::asString(), zypp::url::checkUrlData(), zypp::filesystem::clean_dir(), zypp::target::rpm::RpmDb::doInstallPackage(), zypp::target::rpm::RpmDb::doRebuildDatabase(), zypp::solver::detail::ResolverInfoObsoletes::dumpOn(), zypp::solver::detail::ResolverInfoNeededBy::dumpOn(), zypp::solver::detail::ResolverInfoDependsOn::dumpOn(), zypp::solver::detail::ResolverInfoConflictsWith::dumpOn(), zypp::solver::detail::ResolverInfoChildOf::dumpOn(), zypp::source::PackageProvider::failOnChecksumError(), zypp::base::Unit::form(), zypp::base::ProfilingFormater::format(), zypp::base::LogControl::LineFormater::format(), hexstring(), zypp::solver::detail::ResolverInfoObsoletes::message(), zypp::solver::detail::ResolverInfoNeededBy::message(), zypp::solver::detail::ResolverInfoMissingReq::message(), zypp::solver::detail::ResolverInfoMisc::message(), zypp::solver::detail::ResolverInfoDependsOn::message(), zypp::solver::detail::ResolverInfoConflictsWith::message(), zypp::solver::detail::ResolverInfoChildOf::message(), numstring(), octstring(), zypp::solver::detail::operator<<(), zypp::solver::detail::ProblemSolutionIgnoreArchitecture::ProblemSolutionIgnoreArchitecture(), zypp::solver::detail::ProblemSolutionIgnoreConflicts::ProblemSolutionIgnoreConflicts(), zypp::solver::detail::ProblemSolutionIgnoreInstalled::ProblemSolutionIgnoreInstalled(), zypp::solver::detail::ProblemSolutionIgnoreObsoletes::ProblemSolutionIgnoreObsoletes(), zypp::solver::detail::ProblemSolutionInstall::ProblemSolutionInstall(), zypp::solver::detail::ProblemSolutionKeep::ProblemSolutionKeep(), zypp::solver::detail::ProblemSolutionUninstall::ProblemSolutionUninstall(), zypp::solver::detail::ProblemSolutionUnlock::ProblemSolutionUnlock(), zypp::solver::detail::QueueItemRequire::process(), zypp::source::SourceImpl::provideFile(), zypp::source::SourceImpl::providePackage(), zypp::source::yum::YUMSourceImpl::providePackages(), zypp::source::susetags::SuseTagsImpl::providePackages(), zypp::source::yum::YUMSourceImpl::providePatches(), zypp::source::yum::YUMSourceImpl::providePatterns(), zypp::source::yum::YUMSourceImpl::provideProducts(), zypp::source::yum::YUMSourceImpl::provideSelections(), zypp::url::UrlBase::setHost(), zypp::url::UrlBase::setPort(), zypp::url::UrlBase::setScheme(), and strerror().

std::string std::string zypp::str::strerror ( int  errno_r  ) 

Return string describing the error_r code.

Like strerror, but the numerical value is included in the string as well.

Definition at line 48 of file String.cc.

References form().

Referenced by zypp::media::MediaCD::closeTray(), zypp::media::Mount::getEntries(), zypp::media::MediaCD::openTray(), zypp::ExternalProgram::running(), zypp::externalprogram::ExternalDataSource::setBlocking(), zypp::ExternalProgram::start_program(), zypp::Exception::strErrno(), zypp::filesystem::TmpDir::TmpDir(), and zypp::filesystem::TmpFile::TmpFile().

std::string zypp::str::toLower ( const std::string &  s  ) 

Return lowercase version of s.

Todo:
improve

Definition at line 58 of file String.cc.

Referenced by zypp::media::MediaCurl::attachTo(), zypp::CheckSum::CheckSum(), zypp::url::UrlBase::cleanupPathName(), zypp::solver::detail::HelixControl::deleteResolvable(), zypp::solver::detail::helixXML(), zypp::solver::detail::HelixControl::installResolvable(), zypp::url::UrlBase::isKnownScheme(), zypp::url::UrlBase::isValidScheme(), zypp::KindOf< _Tp >::operator==(), zypp::parse(), zypp::url::UrlBase::setHost(), zypp::url::UrlBase::setPathName(), zypp::url::UrlBase::setScheme(), and zypp::trusted().

std::string zypp::str::toUpper ( const std::string &  s  ) 

Return uppercase version of s.

Todo:
improve

Definition at line 77 of file String.cc.

Referenced by zypp::target::rpm::RpmDb::exportTrustedKeysInZyppKeyRing(), and zypp::url::UrlBase::setHost().

std::string zypp::str::trim ( const std::string &  s,
const Trim  trim_r = TRIM 
)

Definition at line 96 of file String.cc.

References L_TRIM, NO_TRIM, and R_TRIM.

Referenced by _getline(), ltrim(), zypp::base::sysconfig::read(), and rtrim().

std::string zypp::str::stripFirstWord ( std::string &  line,
const bool  ltrim_first 
)

Definition at line 130 of file String.cc.

References ltrim().

Referenced by zypp::SourceFactory::scanProductsFile().

static std::string zypp::str::_getline ( std::istream &  str,
const Trim  trim_r 
) [inline, static]

Definition at line 166 of file String.cc.

References trim().

Referenced by getline().

std::string zypp::str::getline ( std::istream &  str,
const Trim  trim_r 
)

Definition at line 181 of file String.cc.

References _getline().

Referenced by zypp::SourceFactory::scanProductsFile().

std::string zypp::str::getline ( std::istream &  str,
bool  trim = false 
)

Definition at line 186 of file String.cc.

References _getline(), NO_TRIM, and TRIM.

Referenced by zypp::DiskUsageCounter::detectMountPoints(), zypp::storage::XMLFilesBackend::flagsFromFile(), zypp::media::MediaHandler::getDirectoryYast(), zypp::source::SourceImpl::Verifier::isDesiredMedia(), zypp::MediaVerifier::isDesiredMedia(), zypp::source::susetags::ProductMetadataParser::parse(), zypp::source::susetags::MediaPatchesMetadataParser::parse(), zypp::source::susetags::MediaMetadataParser::parse(), zypp::parser::tagfile::TagFileParser::parse(), zypp::source::susetags::SuseTagsImpl::providePatterns(), zypp::source::susetags::SuseTagsImpl::provideSelections(), zypp::base::sysconfig::read(), zypp::source::susetags::SuseTagsImpl::readMediaFile(), zypp::externalprogram::ExternalDataSource::receiveLine(), zypp::SourceCache::removeSource(), and zypp::SourceCache::restoreSources().

std::string zypp::str::numstring ( char  n,
int  w = 0 
) [inline]

Definition at line 107 of file String.h.

References form().

Referenced by zypp::media::MediaCD::detectDevices(), zypp::debug::dumpMemOn(), and zypp::media::MediaManager_Impl::findMM().

std::string zypp::str::numstring ( unsigned char  n,
int  w = 0 
) [inline]

Definition at line 108 of file String.h.

References form().

std::string zypp::str::numstring ( short  n,
int  w = 0 
) [inline]

Definition at line 109 of file String.h.

References form().

std::string zypp::str::numstring ( unsigned short  n,
int  w = 0 
) [inline]

Definition at line 110 of file String.h.

References form().

std::string zypp::str::numstring ( int  n,
int  w = 0 
) [inline]

Definition at line 111 of file String.h.

References form().

std::string zypp::str::numstring ( unsigned  n,
int  w = 0 
) [inline]

Definition at line 112 of file String.h.

References form().

std::string zypp::str::numstring ( long  n,
int  w = 0 
) [inline]

Definition at line 113 of file String.h.

References form().

std::string zypp::str::numstring ( unsigned long  n,
int  w = 0 
) [inline]

Definition at line 114 of file String.h.

References form().

std::string zypp::str::numstring ( long long  n,
int  w = 0 
) [inline]

Definition at line 115 of file String.h.

References form().

std::string zypp::str::numstring ( unsigned long long  n,
int  w = 0 
) [inline]

Definition at line 116 of file String.h.

References form().

Referenced by zypp::media::MediaSource::asString(), zypp::solver::detail::Testcase::createTestcase(), zypp::media::MediaCurl::doGetFileCopy(), zypp::solver::detail::HelixControl::HelixControl(), zypp::solver::detail::helixXML(), zypp::target::rpm::RpmDb::importPubkey(), zypp::solver::detail::HelixControl::installResolvable(), zypp::source::SourceImpl::Verifier::isDesiredMedia(), zypp::MediaVerifier::isDesiredMedia(), zypp::source::MediaSet::rewriteUrl(), and zypp::MediaSetAccess::rewriteUrl().

std::string zypp::str::hexstring ( char  n,
int  w = 4 
) [inline]

Definition at line 131 of file String.h.

References form().

Referenced by zypp::media::MediaHandler::createAttachPoint().

std::string zypp::str::hexstring ( unsigned char  n,
int  w = 4 
) [inline]

Definition at line 132 of file String.h.

References form().

std::string zypp::str::hexstring ( short  n,
int  w = 10 
) [inline]

Definition at line 133 of file String.h.

References form().

std::string zypp::str::hexstring ( unsigned short  n,
int  w = 10 
) [inline]

Definition at line 134 of file String.h.

References form().

std::string zypp::str::hexstring ( int  n,
int  w = 10 
) [inline]

Definition at line 135 of file String.h.

References form().

std::string zypp::str::hexstring ( unsigned  n,
int  w = 10 
) [inline]

Definition at line 136 of file String.h.

References form().

std::string zypp::str::hexstring ( long  n,
int  w = 10 
) [inline]

Definition at line 137 of file String.h.

References form().

std::string zypp::str::hexstring ( unsigned long  n,
int  w = 10 
) [inline]

Definition at line 138 of file String.h.

References form().

std::string zypp::str::hexstring ( long long  n,
int  w = 0 
) [inline]

Definition at line 139 of file String.h.

References form().

std::string zypp::str::hexstring ( unsigned long long  n,
int  w = 0 
) [inline]

Definition at line 140 of file String.h.

References form().

Referenced by zypp::SourceCache::removeSource(), and zypp::SourceCache::storeSource().

std::string zypp::str::octstring ( char  n,
int  w = 4 
) [inline]

Definition at line 155 of file String.h.

References form().

std::string zypp::str::octstring ( unsigned char  n,
int  w = 4 
) [inline]

Definition at line 156 of file String.h.

References form().

std::string zypp::str::octstring ( short  n,
int  w = 5 
) [inline]

Definition at line 157 of file String.h.

References form().

std::string zypp::str::octstring ( unsigned short  n,
int  w = 5 
) [inline]

Definition at line 158 of file String.h.

References form().

std::string zypp::str::octstring ( int  n,
int  w = 5 
) [inline]

Definition at line 159 of file String.h.

References form().

std::string zypp::str::octstring ( unsigned  n,
int  w = 5 
) [inline]

Definition at line 160 of file String.h.

References form().

std::string zypp::str::octstring ( long  n,
int  w = 5 
) [inline]

Definition at line 161 of file String.h.

References form().

std::string zypp::str::octstring ( unsigned long  n,
int  w = 5 
) [inline]

Definition at line 162 of file String.h.

References form().

std::string zypp::str::octstring ( long long  n,
int  w = 0 
) [inline]

Definition at line 163 of file String.h.

References form().

std::string zypp::str::octstring ( unsigned long long  n,
int  w = 0 
) [inline]

Definition at line 164 of file String.h.

References form().

Referenced by zypp::filesystem::chmod(), and zypp::filesystem::mkdir().

template<typename _It>
unsigned long long zypp::str::strtonum ( const std::string &  str  )  [inline]

String to integer type determined by template arg.

Note:
Only specializations are defined.
 time_t t = strtonum<time_t>( "42" );

Definition at line 181 of file String.h.

template<typename _It>
_It zypp::str::strtonum ( const std::string &  str,
_It &  i 
) [inline]

String to integer type detemined 2nd function arg i.

 time_t t; strtonum( "42", t );

Definition at line 204 of file String.h.

Referenced by zypp::source::susetags::MediaMetadataParser::parse().

template<class _OutputIterator>
unsigned zypp::str::split ( const std::string &  line_r,
_OutputIterator  result_r,
const std::string &  sepchars_r = " \t" 
)

Split line_r into words.

Any sequence of characters in sepchars_r is treated as delimiter. The words are passed to OutputIterator result_r.

 std::vector<std::string> words;
 str::split( "some line", std::back_inserter(words) )

Definition at line 221 of file String.h.

Referenced by zypp::source::susetags::PatternTagFileParser::consume(), zypp::source::susetags::PackagesParser::consume(), zypp::source::susetags::PackageDiskUsageParser::consume(), zypp::source::susetags::PackagesLangParser::consume(), log_curl(), and zypp::media::ProxyInfoSysconfig::ProxyInfoSysconfig().

template<class _Iterator>
std::string zypp::str::join ( _Iterator  begin,
_Iterator  end,
const std::string &  sep_r = " " 
)

Join strings using separator sep_r (defaults to BLANK).

Definition at line 251 of file String.h.

Referenced by join().

template<class _Container>
std::string zypp::str::join ( const _Container &  cont_r,
const std::string &  sep_r = " " 
)

Join strings using separator sep_r (defaults to BLANK).

Definition at line 266 of file String.h.

References join().

std::string zypp::str::ltrim ( const std::string &  s  )  [inline]

Definition at line 301 of file String.h.

References L_TRIM, and trim().

Referenced by stripFirstWord().

std::string zypp::str::rtrim ( const std::string &  s  )  [inline]

Definition at line 304 of file String.h.

References R_TRIM, and trim().

Referenced by zypp::media::MediaDISK::verifyIfDiskVolume().


Generated on Tue Nov 28 16:49:41 2006 for zypp by  doxygen 1.5.0