CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
string.h File Reference
#include <stdint.h>
#include <sys/time.h>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
#include "util/export.h"
Include dependency graph for string.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

CVMFS_EXPORT std::string StringifyBool (const bool value)
 
CVMFS_EXPORT std::string StringifyInt (const int64_t value)
 
CVMFS_EXPORT std::string StringifyUint (const uint64_t value)
 
CVMFS_EXPORT std::string StringifyByteAsHex (const unsigned char value)
 
CVMFS_EXPORT std::string StringifyDouble (const double value)
 
CVMFS_EXPORT std::string StringifyTime (const time_t seconds, const bool utc)
 
CVMFS_EXPORT std::string StringifyLocalTime (const time_t seconds)
 
CVMFS_EXPORT std::string StringifyTimeval (const timeval value)
 
CVMFS_EXPORT std::string RfcTimestamp ()
 
CVMFS_EXPORT std::string IsoTimestamp ()
 
CVMFS_EXPORT std::string WhitelistTimestamp (time_t when)
 
CVMFS_EXPORT time_t IsoTimestamp2UtcTime (const std::string &iso8601)
 
CVMFS_EXPORT int64_t String2Int64 (const std::string &value)
 
CVMFS_EXPORT uint64_t String2Uint64 (const std::string &value)
 
CVMFS_EXPORT bool String2Uint64Parse (const std::string &value, uint64_t *result)
 
CVMFS_EXPORT void String2Uint64Pair (const std::string &value, uint64_t *a, uint64_t *b)
 
CVMFS_EXPORT bool HasPrefix (const std::string &str, const std::string &prefix, const bool ignore_case)
 
CVMFS_EXPORT bool HasSuffix (const std::string &str, const std::string &suffix, const bool ignore_case)
 
CVMFS_EXPORT std::vector
< std::string > 
SplitStringBounded (unsigned max_chunks, const std::string &str, char delim)
 
CVMFS_EXPORT std::vector
< std::string > 
SplitString (const std::string &str, char delim)
 
CVMFS_EXPORT std::string JoinStrings (const std::vector< std::string > &strings, const std::string &joint)
 
CVMFS_EXPORT void ParseKeyvalMem (const unsigned char *buffer, const unsigned buffer_size, std::map< char, std::string > *content)
 
CVMFS_EXPORT bool ParseKeyvalPath (const std::string &filename, std::map< char, std::string > *content)
 
CVMFS_EXPORT std::string GetLineMem (const char *text, const int text_size)
 
CVMFS_EXPORT bool GetLineFile (FILE *f, std::string *line)
 
CVMFS_EXPORT bool GetLineFd (const int fd, std::string *line)
 
CVMFS_EXPORT std::string Trim (const std::string &raw, bool trim_newline=false)
 
CVMFS_EXPORT std::string TrimString (const std::string &path, const std::string &toTrim, const int trimMode=kTrimAll)
 
CVMFS_EXPORT std::string ToUpper (const std::string &mixed_case)
 
CVMFS_EXPORT std::string ReplaceAll (const std::string &haystack, const std::string &needle, const std::string &replace_by)
 
CVMFS_EXPORT std::string Tail (const std::string &source, unsigned num_lines)
 
CVMFS_EXPORT std::string Base64 (const std::string &data)
 
CVMFS_EXPORT std::string Base64Url (const std::string &data)
 
CVMFS_EXPORT bool Debase64 (const std::string &data, std::string *decoded)
 
CVMFS_EXPORT std::string GetGMTimestamp (const std::string &format="%Y-%m-%d %H:%M:%S")
 

Variables

const int kTrimNone = 0
 
const int kTrimLeading = 1 << 0
 
const int kTrimTrailing = 1 << 1
 
const int kTrimAll = kTrimLeading | kTrimTrailing
 

Function Documentation

CVMFS_EXPORT std::string Base64 ( const std::string &  data)
CVMFS_EXPORT std::string Base64Url ( const std::string &  data)
CVMFS_EXPORT bool Debase64 ( const std::string &  data,
std::string *  decoded 
)
CVMFS_EXPORT std::string GetGMTimestamp ( const std::string &  format)

Get UTC Time.

Parameters
formatformat if timestamp (YYYY-MM-DD HH:MM:SS by default)
Returns
a timestamp string on success, empty string on failure

Definition at line 633 of file string.cc.

Referenced by swissknife::CommandGc::Main(), swissknife::Ingest::Main(), main(), swissknife::CommandSync::Main(), StatisticsDatabase::StoreGCStatistics(), and StatisticsDatabase::StorePublishStatistics().

Here is the caller graph for this function:

CVMFS_EXPORT bool GetLineFd ( const int  fd,
std::string *  line 
)

Definition at line 422 of file string.cc.

Referenced by FuseMain(), BashOptionsManager::ParsePath(), manifest::Reflog::ReadChecksum(), and publish::SetInConfig().

Here is the caller graph for this function:

CVMFS_EXPORT std::string GetLineMem ( const char *  text,
const int  text_size 
)
CVMFS_EXPORT bool HasPrefix ( const std::string &  str,
const std::string &  prefix,
const bool  ignore_case 
)
CVMFS_EXPORT std::string IsoTimestamp ( )

Current time in format YYYYMMDDTHHMMSSZ. Used in AWS4 requests.

Definition at line 167 of file string.cc.

Referenced by s3fanout::S3FanoutManager::MkV4Authz().

Here is the caller graph for this function:

CVMFS_EXPORT time_t IsoTimestamp2UtcTime ( const std::string &  iso8601)

Parses a timestamp of the form YYYY-MM-DDTHH:MM:SSZ Return 0 on error

Definition at line 216 of file string.cc.

Referenced by MountPoint::DetermineRootHash().

Here is the call graph for this function:

Here is the caller graph for this function:

CVMFS_EXPORT std::string JoinStrings ( const std::vector< std::string > &  strings,
const std::string &  joint 
)
CVMFS_EXPORT void ParseKeyvalMem ( const unsigned char *  buffer,
const unsigned  buffer_size,
std::map< char, std::string > *  content 
)
CVMFS_EXPORT bool ParseKeyvalPath ( const std::string &  filename,
std::map< char, std::string > *  content 
)
CVMFS_EXPORT std::string ReplaceAll ( const std::string &  haystack,
const std::string &  needle,
const std::string &  replace_by 
)
CVMFS_EXPORT std::vector<std::string> SplitString ( const std::string &  str,
char  delim 
)
CVMFS_EXPORT std::vector<std::string> SplitStringBounded ( unsigned  max_chunks,
const std::string &  str,
char  delim 
)
CVMFS_EXPORT int64_t String2Int64 ( const std::string &  value)
CVMFS_EXPORT uint64_t String2Uint64 ( const std::string &  value)
CVMFS_EXPORT void String2Uint64Pair ( const std::string &  value,
uint64_t *  a,
uint64_t *  b 
)
CVMFS_EXPORT bool String2Uint64Parse ( const std::string &  value,
uint64_t *  result 
)

Parse a string into a a uint64_t.

Unlike String2Uint64, this:

  • Checks to make sure the full string is parsed
  • Can indicate an error occurred.

If an error occurs, this returns false and sets errno appropriately.

Definition at line 263 of file string.cc.

Referenced by publish::SyncItem::CheckGraft(), CloseAllFildesInProcSelfFd(), AuthzExternalFetcher::ExecHelper(), catalog::ClientCatalogManager::IsRevisionBlacklisted(), swissknife::CommandGraft::Main(), main(), Url::Parse(), and Url::ValidateHost().

Here is the caller graph for this function:

CVMFS_EXPORT std::string StringifyBool ( const bool  value)

Definition at line 76 of file string.cc.

Referenced by manifest::Manifest::ExportString(), swissknife::CommandInfo::Main(), and TalkManager::MainResponder().

Here is the caller graph for this function:

CVMFS_EXPORT std::string StringifyByteAsHex ( const unsigned char  value)

Definition at line 90 of file string.cc.

CVMFS_EXPORT std::string StringifyDouble ( const double  value)
CVMFS_EXPORT std::string StringifyInt ( const int64_t  value)

Definition at line 78 of file string.cc.

Referenced by anonymous_namespace{pack.cc}::AppendItemToHeader(), PosixQuotaManager::BindReturnPipe(), swissknife::CommandListCatalogs::CatalogCallback(), swissknife::CommandFileStats::CatalogCallback(), catalog::WritableCatalog::CopyToParent(), PosixQuotaManager::CreateShared(), publish::CmdEnter::CreateUnderlay(), CreateUserNamespace(), cvmfs_options_clone_legacy(), cvmfs_options_init_legacy(), sqlite::Sql::DebugResultTable(), RamCacheManager::Describe(), upload::SessionContext::DoUpload(), anonymous_namespace{cmd_enter.cc}::EnterRootContainer(), swissknife::Error(), manifest::Manifest::ExportString(), AuthzExternalFetcher::Fetch(), download::DownloadManager::Fetch(), catalog::ClientCatalogManager::FetchCatalogByHash(), MountPoint::FetchHistory(), LHashMagicXattr::FinalizeValue(), NCleanup24MagicXattr::FinalizeValue(), NClgMagicXattr::FinalizeValue(), NIOErrMagicXattr::FinalizeValue(), RxMagicXattr::FinalizeValue(), SpeedMagicXattr::FinalizeValue(), TimestampLastIOErrMagicXattr::FinalizeValue(), ExpiresMagicXattr::FinalizeValue(), InodeMaxMagicXattr::FinalizeValue(), MaxFdMagicXattr::FinalizeValue(), PidMagicXattr::FinalizeValue(), JsonStringGenerator::JsonEntry::Format(), TalkManager::FormatHostInfo(), TalkManager::FormatProxyInfo(), FuseMain(), swissknife::CommandMigrate::ChownMigrationWorker::GenerateMappingStatement(), Watchdog::GenerateStackTrace(), catalog::TreeCountersBase< FieldT >::GetCsvMap(), CachePlugin::HandleHandshake(), AuthzExternalFetcher::Handshake(), swissknife::CommandInfoTag::HumanReadableFilesize(), Init(), PosixQuotaManager::InitDatabase(), anonymous_namespace{pack.cc}::InitializeHeader(), FileSystem::LockWorkspace(), CachePlugin::LogSessionError(), CachePlugin::LogSessionInfo(), swissknife::CommandInfo::Main(), swissknife::CommandPull::Main(), publish::CmdEnter::Main(), main(), PosixQuotaManager::MainCacheManager(), Tracer::MainFlush(), swissknife::CommandFileStats::MainProcessing(), TalkManager::MainResponder(), MaintenanceMode(), MakeAcquireRequest(), anonymous_namespace{repository_session.cc}::MakeAcquireRequest(), perf::TelemetryAggregatorInflux::MakeDeltaPayload(), publish::SettingsStorage::MakeGateway(), perf::TelemetryAggregatorInflux::MakePayload(), PosixQuotaManager::MakeReturnPipe(), s3fanout::S3FanoutManager::MkAzureAuthz(), publish::CmdEnter::MountCvmfs(), publish::CmdEnter::MountOverlayfs(), ChunkListMagicXattr::PrepareValueFenced(), perf::Counter::Print(), s3fanout::Statistics::Print(), download::DownloadManager::ProxyInfo::Print(), glue::InodeTracker::Statistics::Print(), swissknife::CommandListTags::PrintHumanReadableTagList(), cvmfs::PrintInodeGeneration(), perf::Counter::PrintK(), perf::Counter::PrintKi(), perf::Counter::PrintM(), catalog::Catalog::PrintMemStatistics(), perf::Counter::PrintMi(), JsonDocument::PrintValue(), swissknife::CommandGraft::Publish(), publish::Publisher(), loader::Reload(), anonymous_namespace{cmd_enter.cc}::RemoveSingle(), anonymous_namespace{cmd_enter.cc}::RemoveUnderlay(), swissknife::CommandMigrate::StatsMigrationWorker::RepairStatisticsCounters(), Watchdog::ReportStacktrace(), RestoreState(), publish::RunSuidHelper(), SaveState(), Watchdog::SendTrace(), FileSystem::SetupCrashGuard(), letter::Letter::Sign(), ExternalCacheManager::SpawnPlugin(), catalog::SqlAllChunks::SqlAllChunks(), Watchdog::Supervise(), download::DownloadManager::SwitchHost(), notify::msg::Activity::ToJSONString(), manifest::Breadcrumb::ToString(), perf::Counter::ToString(), PosixQuotaManager::UnlinkReturnPipe(), Url::Url(), and AuthzExternalFetcher::~AuthzExternalFetcher().

CVMFS_EXPORT std::string StringifyLocalTime ( const time_t  seconds)

Converts seconds since UTC 0 into something like 12 Sep 14:59:37 CDT

Definition at line 126 of file string.cc.

Referenced by LogBufferXattr::FinalizeValue().

Here is the caller graph for this function:

CVMFS_EXPORT std::string StringifyTimeval ( const timeval  value)

Definition at line 203 of file string.cc.

Referenced by Tracer::MainFlush().

Here is the caller graph for this function:

CVMFS_EXPORT std::string Tail ( const std::string &  source,
unsigned  num_lines 
)
CVMFS_EXPORT std::string ToUpper ( const std::string &  mixed_case)
CVMFS_EXPORT std::string Trim ( const std::string &  raw,
bool  trim_newline = false 
)
CVMFS_EXPORT std::string TrimString ( const std::string &  path,
const std::string &  toTrim,
const int  trimMode = kTrimAll 
)

Definition at line 468 of file string.cc.

Referenced by swissknife::Ingest::Main().

Here is the call graph for this function:

Here is the caller graph for this function:

CVMFS_EXPORT std::string WhitelistTimestamp ( time_t  when)

UTC time in format YYYYMMDDHHMMSS. Used in cvmfs whitelists.

Definition at line 187 of file string.cc.

Referenced by whitelist::Whitelist::CreateString().

Here is the caller graph for this function:

Variable Documentation

const int kTrimAll = kTrimLeading | kTrimTrailing

Definition at line 21 of file string.h.

Referenced by swissknife::Ingest::Main().

const int kTrimLeading = 1 << 0

Definition at line 19 of file string.h.

Referenced by TrimString().

const int kTrimNone = 0

This file is part of the CernVM File System.

Definition at line 18 of file string.h.

const int kTrimTrailing = 1 << 1

Definition at line 20 of file string.h.

Referenced by TrimString().