CernVM-FS  2.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
string.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_UTIL_STRING_H_
6 #define CVMFS_UTIL_STRING_H_
7 
8 #include <stdint.h>
9 #include <sys/time.h>
10 
11 #include <cstdio>
12 #include <map>
13 #include <string>
14 #include <vector>
15 
16 #ifdef CVMFS_NAMESPACE_GUARD
17 namespace CVMFS_NAMESPACE_GUARD {
18 #endif
19 
20 std::string StringifyBool(const bool value);
21 std::string StringifyInt(const int64_t value);
22 std::string StringifyUint(const uint64_t value);
23 std::string StringifyByteAsHex(const unsigned char value);
24 std::string StringifyDouble(const double value);
25 std::string StringifyTime(const time_t seconds, const bool utc);
26 std::string StringifyTimeval(const timeval value);
27 std::string RfcTimestamp();
28 std::string IsoTimestamp();
29 std::string WhitelistTimestamp(time_t when);
30 time_t IsoTimestamp2UtcTime(const std::string &iso8601);
31 int64_t String2Int64(const std::string &value);
32 uint64_t String2Uint64(const std::string &value);
33 bool String2Uint64Parse(const std::string &value, uint64_t *result);
34 
35 void String2Uint64Pair(const std::string &value, uint64_t *a, uint64_t *b);
36 bool HasPrefix(const std::string &str, const std::string &prefix,
37  const bool ignore_case);
38 bool HasSuffix(const std::string &str, const std::string &suffix,
39  const bool ignore_case);
40 
41 std::vector<std::string> SplitString(const std::string &str, const char delim,
42  const unsigned max_chunks = 0);
43 std::string JoinStrings(const std::vector<std::string> &strings,
44  const std::string &joint);
45 void ParseKeyvalMem(const unsigned char *buffer, const unsigned buffer_size,
46  std::map<char, std::string> *content);
47 bool ParseKeyvalPath(const std::string &filename,
48  std::map<char, std::string> *content);
49 
50 std::string GetLineMem(const char *text, const int text_size);
51 bool GetLineFile(FILE *f, std::string *line);
52 bool GetLineFd(const int fd, std::string *line);
53 std::string Trim(const std::string &raw, bool trim_newline = false);
54 std::string ToUpper(const std::string &mixed_case);
55 std::string ReplaceAll(const std::string &haystack, const std::string &needle,
56  const std::string &replace_by);
57 std::string Tail(const std::string &source, unsigned num_lines);
58 
59 std::string Base64(const std::string &data);
60 std::string Base64Url(const std::string &data);
61 bool Debase64(const std::string &data, std::string *decoded);
62 std::string GetGMTimestamp(const std::string &format = "%Y-%m-%d %H:%M:%S");
63 
64 
65 #ifdef CVMFS_NAMESPACE_GUARD
66 } // namespace CVMFS_NAMESPACE_GUARD
67 #endif
68 
69 #endif // CVMFS_UTIL_STRING_H_
string GetLineMem(const char *text, const int text_size)
Definition: string.cc:373
std::string GetGMTimestamp(const std::string &format)
Definition: string.cc:585
vector< string > SplitString(const string &str, const char delim, const unsigned max_chunks)
Definition: string.cc:288
std::string IsoTimestamp()
Definition: string.cc:149
string Trim(const string &raw, bool trim_newline)
Definition: string.cc:421
string ReplaceAll(const string &haystack, const string &needle, const string &replace_by)
Definition: string.cc:454
string JoinStrings(const vector< string > &strings, const string &joint)
Definition: string.cc:318
string Tail(const string &source, unsigned num_lines)
Definition: string.cc:562
string StringifyTime(const time_t seconds, const bool utc)
Definition: string.cc:105
string StringifyDouble(const double value)
Definition: string.cc:96
std::string StringifyUint(const uint64_t value)
Definition: string.cc:84
bool Debase64(const string &data, string *decoded)
Definition: string.cc:534
string StringifyByteAsHex(const unsigned char value)
Definition: string.cc:90
string StringifyBool(const bool value)
Definition: string.cc:76
bool String2Uint64Parse(const std::string &value, uint64_t *result)
Definition: string.cc:243
string Base64Url(const string &data)
Definition: string.cc:505
std::string RfcTimestamp()
Definition: string.cc:127
int64_t String2Int64(const string &value)
Definition: string.cc:222
bool GetLineFile(FILE *f, std::string *line)
Definition: string.cc:379
string ToUpper(const string &mixed_case)
Definition: string.cc:446
bool HasSuffix(const std::string &str, const std::string &suffix, const bool ignore_case)
Definition: string.cc:279
std::string WhitelistTimestamp(time_t when)
Definition: string.cc:169
string StringifyInt(const int64_t value)
Definition: string.cc:78
bool HasPrefix(const string &str, const string &prefix, const bool ignore_case)
Definition: string.cc:265
time_t IsoTimestamp2UtcTime(const std::string &iso8601)
Definition: string.cc:198
bool GetLineFd(const int fd, std::string *line)
Definition: string.cc:397
string Base64(const string &data)
Definition: string.cc:474
uint64_t String2Uint64(const string &value)
Definition: string.cc:228
bool ParseKeyvalPath(const string &filename, map< char, string > *content)
Definition: string.cc:359
string StringifyTimeval(const timeval value)
Definition: string.cc:185
void ParseKeyvalMem(const unsigned char *buffer, const unsigned buffer_size, map< char, string > *content)
Definition: string.cc:330
void String2Uint64Pair(const string &value, uint64_t *a, uint64_t *b)
Definition: string.cc:261