CernVM-FS
2.12.0
|
#include <stdint.h>
#include <sys/time.h>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
#include "util/export.h"
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 |
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.
format | format if timestamp (YYYY-MM-DD HH:MM:SS by default) |
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().
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().
CVMFS_EXPORT bool GetLineFile | ( | FILE * | f, |
std::string * | line | ||
) |
Definition at line 404 of file string.cc.
Referenced by publish::SyncItem::CheckGraft(), cvmfs::Uuid::Create(), publish::CheckoutMarker::CreateFrom(), ResolvConfEventHandler::GetDnsAddresses(), swissknife::CommandLease::Main(), SpecTree::Parse(), catalog::Dirtab::Parse(), dns::HostfileResolver::ParseHostFile(), BashOptionsManager::ParsePath(), upload::GatewayUploader::ReadSessionTokenFile(), and SimpleOptionsParser::TryParsePath().
CVMFS_EXPORT std::string GetLineMem | ( | const char * | text, |
const int | text_size | ||
) |
Definition at line 398 of file string.cc.
Referenced by signature::SignatureManager::LoadBlacklist(), catalog::Dirtab::Parse(), ObjectPackConsumer::ParseHeader(), gateway::ParseKey(), and whitelist::Whitelist::ParseWhitelist().
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 | ||
) |
Definition at line 299 of file string.cc.
Referenced by PluginRamCache::Create(), s3fanout::S3FanoutManager::DetectThrottleIndicator(), swissknife::CommandScrub::DirCallback(), upload::S3Uploader::DoUpload(), anonymous_namespace{ssl.cc}::HasCertificates(), FileSystem::SetupRamCacheMgr(), shash::Digest< 16, kMd5 >::ToFingerprint(), shash::Digest< 16, kMd5 >::ToString(), TrimString(), and sqlite::VfsRdOnlyAccess().
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().
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().
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::string RfcTimestamp | ( | ) |
Current time in format Wed, 01 Mar 2006 12:00:00 GMT
Definition at line 145 of file string.cc.
Referenced by GarbageCollector< CatalogTraversalT, HashFilterT >::AnalyzePreservedCatalogTree(), s3fanout::S3FanoutManager::MkAzureAuthz(), s3fanout::S3FanoutManager::MkV2Authz(), GarbageCollector< CatalogTraversalT, HashFilterT >::SweepDataObjects(), and GarbageCollector< CatalogTraversalT, HashFilterT >::SweepReflog().
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:
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().
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().
CVMFS_EXPORT std::string StringifyByteAsHex | ( | const unsigned char | value | ) |
CVMFS_EXPORT std::string StringifyDouble | ( | const double | value | ) |
Definition at line 96 of file string.cc.
Referenced by sqlite::Sql::DebugResultTable(), HitrateMagicXattr::FinalizeValue(), JsonStringGenerator::JsonEntry::Format(), swissknife::CommandInfoTag::HumanReadableFilesize(), perf::Counter::PrintRatio(), and JsonDocument::PrintValue().
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().
CVMFS_EXPORT std::string StringifyTime | ( | const time_t | seconds, |
const bool | utc | ||
) |
Converts seconds since UTC 0 into something readable
Definition at line 105 of file string.cc.
Referenced by GarbageCollectorAux< CatalogTraversalT, HashFilterT >::CollectOlderThan(), MountPoint::DetermineRootHash(), notify::DoPublish(), catalog::ClientCatalogManager::GetNewRootCatalogContext(), swissknife::CommandGc::Main(), TalkManager::MainResponder(), anonymous_namespace{cmd_diff.cc}::DiffReporter::OnInit(), whitelist::Whitelist::ParseWhitelist(), GarbageCollector< CatalogTraversalT, HashFilterT >::PreserveDataObjects(), swissknife::CommandInfoTag::PrintHumanReadableInfo(), swissknife::CommandListTags::PrintHumanReadableTagList(), swissknife::CommandPull::Pull(), and GarbageCollector< CatalogTraversalT, HashFilterT >::SweepDataObjects().
CVMFS_EXPORT std::string StringifyTimeval | ( | const timeval | value | ) |
Definition at line 203 of file string.cc.
Referenced by Tracer::MainFlush().
CVMFS_EXPORT std::string StringifyUint | ( | const uint64_t | value | ) |
Definition at line 84 of file string.cc.
Referenced by cvmfs::MemSink::Describe(), download::DownloadManager::Fetch(), ChunksMagicXattr::FinalizeValue(), ExternalTimeoutMagicXattr::FinalizeValue(), NCleanup24MagicXattr::FinalizeValue(), RevisionMagicXattr::FinalizeValue(), TimeoutMagicXattr::FinalizeValue(), TimeoutDirectMagicXattr::FinalizeValue(), UptimeMagicXattr::FinalizeValue(), receiver::GenerateSessionToken(), StatisticsDatabase::GetDBParams(), swissknife::CommandGraft::GetParams(), BaseMagicXattr::GetValue(), receiver::Reactor::HandleRequest(), BaseMagicXattr::HeaderMultipageHuman(), TalkManager::MainResponder(), perf::TelemetryAggregatorInflux::MakeDeltaPayload(), perf::TelemetryAggregatorInflux::MakePayload(), ChunkListMagicXattr::PrepareValueFenced(), StatisticsDatabase::Prune(), MagicXattrManager::SanityCheckProtectedXattrs(), download::DownloadManager::SwitchProxyGroup(), manifest::Breadcrumb::ToString(), and Log2Histogram::ToString().
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().
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().
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 |
const int kTrimTrailing = 1 << 1 |
Definition at line 20 of file string.h.
Referenced by TrimString().