OdbDesign
OdbDesign ODB++ Parser - C++ library, gRPC/REST server, CLI, tests
 
Loading...
Searching...
No Matches
Utils Namespace Reference

Namespaces

namespace  Tracing
 

Classes

class  ArchiveExtractor
 
class  CommandLineArgs
 
class  CrossPlatform
 
class  CrowReturnable
 
class  EnumMap
 
class  FileReader
 
class  IJsonable
 
class  JsonCrowReturnable
 
class  Logger
 
class  StopWatch
 
class  ThreadSafeQueue
 
class  UrlEncoding
 
class  WorkQueueLoopThread
 

Typedefs

typedef std::vector< std::string > StringVector
 

Enumerations

enum class  ExitCode {
  Success = 0 , FailedInit = 1 , FailedInitSsl = 2 , FailedInitSslDirDoesNotExist = 3 ,
  FailedInitLoadDesign = 4 , PreServerRunFailed = 5 , PostServerRunFailed = 6 , UnknownError = 7
}
 
enum class  CompressionType { TarGzip }
 

Functions

UTILS_EXPORT std::string hex2bin (const std::string &s)
 
UTILS_EXPORT std::string bin2hex (const std::string &s)
 
UTILS_EXPORT std::string b64_encode (const std::string &s)
 
UTILS_EXPORT std::string b64_decode (const std::string &s)
 
bool float_equals (float a, float b, float epsilon)
 
bool double_equals (double a, double b, double epsilon)
 
template<class R >
bool equals_within (const R a, const R b, const R epsilon=0.001f)
 
std::uint64_t Fnv1a64 (const char *data, std::size_t sizeBytes, std::uint64_t hash=FNV1A64_OFFSET_BASIS)
 
std::string MakeEtag (const std::string &designName, std::int64_t mtimeTicks, std::uint64_t sizeBytes, const std::string &endpointPath, std::uint64_t generation=0)
 
std::filesystem::path FindDesignArchiveFile (const std::string &designsDir, const std::string &designName)
 
std::string MakeDesignEtag (const std::string &designsDir, const std::string &designName, const std::string &endpointPath, std::uint64_t generation=0)
 
bool IfNoneMatchMatches (const std::string &header, const std::string &etag)
 
void move_file (const path &source, const path &dest, bool overwriteExisting, std::error_code &ec)
 
void fastmove_file (const path &source, const path &dest, bool overwriteExisting, std::error_code &ec)
 
UTILS_EXPORT void move_file (const std::filesystem::path &source, const std::filesystem::path &dest, bool overwriteExisting, std::error_code &ec)
 
UTILS_EXPORT void fastmove_file (const std::filesystem::path &source, const std::filesystem::path &dest, bool overwriteExisting, std::error_code &ec)
 
bool extract (const char *filename, const char *destDir)
 
bool compress_dir (const char *srcDir, const char *destDir, const char *archiveName, std::string &fileOut, CompressionType type)
 
bool is_safe_filename_component (const std::string &name)
 
bool is_safe_relative_entry_path (const std::string &name)
 
std::int64_t run_process (const std::string &program, const std::vector< std::string > &args, bool discardOutput)
 
std::string & str_ltrim (std::string &s)
 
std::string & str_rtrim (std::string &s)
 
std::string & str_trim (std::string &s)
 
std::string & str_ltrim (std::string &s, char toRemove)
 
std::string & str_rtrim (std::string &s, char toRemove)
 
std::string & str_trim (std::string &s, char toRemove)
 
std::string str_ltrim_copy (const std::string &s)
 
std::string str_rtrim_copy (const std::string &s)
 
std::string str_trim_copy (const std::string &s)
 
std::string str_ltrim_copy (const std::string &s, char toRemove)
 
std::string str_rtrim_copy (const std::string &s, char toRemove)
 
std::string str_trim_copy (const std::string &s, char toRemove)
 
void str_to_lower (std::string &s)
 
void str_to_upper (std::string &s)
 
std::string str_to_lower_copy (const std::string &s)
 
std::string str_to_upper_copy (const std::string &s)
 
bool str_iequals (const std::string &s1, const std::string &s2)
 
std::vector< std::string >::iterator find_str_icmp (std::vector< std::string >::iterator first, std::vector< std::string >::iterator last, const std::string &val)
 
std::vector< std::string >::const_iterator find_str_icmp (const std::vector< std::string >::const_iterator first, const std::vector< std::string >::const_iterator last, const std::string &val)
 
std::string make_timestamp (const system_clock::time_point &timepoint)
 
std::string make_timestamp ()
 
system_clock::time_point parse_timestamp (const std::string &timestamp, const std::string &format)
 
std::string UTILS_EXPORT make_timestamp (const std::chrono::system_clock::time_point &timepoint)
 

Variables

std::mutex localtimeMutex
 
constexpr std::uint64_t FNV1A64_OFFSET_BASIS = 14695981039346656037ull
 
constexpr std::uint64_t FNV1A64_PRIME = 1099511628211ull
 
const int MS_PER_S = 1000
 

Typedef Documentation

◆ StringVector

typedef std::vector<std::string> Utils::StringVector

Definition at line 8 of file StringVector.h.

Enumeration Type Documentation

◆ CompressionType

enum class Utils::CompressionType
strong
Enumerator
TarGzip 

Definition at line 8 of file libarchive_extract.h.

◆ ExitCode

enum class Utils::ExitCode
strong
Enumerator
Success 
FailedInit 
FailedInitSsl 
FailedInitSslDirDoesNotExist 
FailedInitLoadDesign 
PreServerRunFailed 
PostServerRunFailed 
UnknownError 

Definition at line 6 of file ExitCode.h.

Function Documentation

◆ b64_decode()

UTILS_EXPORT std::string Utils::b64_decode ( const std::string &  s)
inline

Definition at line 87 of file bin2ascii.h.

◆ b64_encode()

UTILS_EXPORT std::string Utils::b64_encode ( const std::string &  s)
inline

Definition at line 60 of file bin2ascii.h.

◆ bin2hex()

UTILS_EXPORT std::string Utils::bin2hex ( const std::string &  s)
inline

Definition at line 46 of file bin2ascii.h.

◆ compress_dir()

UTILS_EXPORT bool Utils::compress_dir ( const char *  srcDir,
const char *  destDir,
const char *  archiveName,
std::string &  fileOut,
CompressionType  type 
)

Definition at line 374 of file libarchive_extract.cpp.

Here is the caller graph for this function:

◆ double_equals()

UTILS_EXPORT bool Utils::double_equals ( double  a,
double  b,
double  epsilon 
)

Definition at line 11 of file equals_within.cpp.

◆ equals_within()

template<class R >
bool Utils::equals_within ( const R  a,
const R  b,
const R  epsilon = 0.001f 
)

Definition at line 9 of file equals_within.h.

◆ extract()

bool Utils::extract ( const char *  filename,
const char *  destDir 
)

Definition at line 113 of file libarchive_extract.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fastmove_file() [1/2]

void Utils::fastmove_file ( const path &  source,
const path &  dest,
bool  overwriteExisting,
std::error_code &  ec 
)

Definition at line 24 of file fastmove.cpp.

Here is the call graph for this function:

◆ fastmove_file() [2/2]

UTILS_EXPORT void Utils::fastmove_file ( const std::filesystem::path &  source,
const std::filesystem::path &  dest,
bool  overwriteExisting,
std::error_code &  ec 
)

◆ find_str_icmp() [1/2]

UTILS_EXPORT std::vector< std::string >::const_iterator Utils::find_str_icmp ( const std::vector< std::string >::const_iterator  first,
const std::vector< std::string >::const_iterator  last,
const std::string &  val 
)

Definition at line 145 of file str_utils.cpp.

◆ find_str_icmp() [2/2]

UTILS_EXPORT std::vector< std::string >::iterator Utils::find_str_icmp ( std::vector< std::string >::iterator  first,
std::vector< std::string >::iterator  last,
const std::string &  val 
)

Definition at line 140 of file str_utils.cpp.

Here is the caller graph for this function:

◆ FindDesignArchiveFile()

std::filesystem::path Utils::FindDesignArchiveFile ( const std::string &  designsDir,
const std::string &  designName 
)
inline

Definition at line 83 of file ETag.h.

Here is the caller graph for this function:

◆ float_equals()

UTILS_EXPORT bool Utils::float_equals ( float  a,
float  b,
float  epsilon 
)

Definition at line 5 of file equals_within.cpp.

◆ Fnv1a64()

std::uint64_t Utils::Fnv1a64 ( const char *  data,
std::size_t  sizeBytes,
std::uint64_t  hash = FNV1A64_OFFSET_BASIS 
)
inline

Definition at line 37 of file ETag.h.

Here is the caller graph for this function:

◆ hex2bin()

UTILS_EXPORT std::string Utils::hex2bin ( const std::string &  s)
inline

Definition at line 12 of file bin2ascii.h.

◆ IfNoneMatchMatches()

bool Utils::IfNoneMatchMatches ( const std::string &  header,
const std::string &  etag 
)
inline

Definition at line 152 of file ETag.h.

Here is the caller graph for this function:

◆ is_safe_filename_component()

bool Utils::is_safe_filename_component ( const std::string &  name)

Definition at line 72 of file PathSafety.cpp.

◆ is_safe_relative_entry_path()

bool Utils::is_safe_relative_entry_path ( const std::string &  name)

Definition at line 103 of file PathSafety.cpp.

Here is the caller graph for this function:

◆ make_timestamp() [1/3]

std::string UTILS_EXPORT Utils::make_timestamp ( )

Definition at line 39 of file timestamp.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_timestamp() [2/3]

std::string UTILS_EXPORT Utils::make_timestamp ( const std::chrono::system_clock::time_point &  timepoint)

◆ make_timestamp() [3/3]

std::string Utils::make_timestamp ( const system_clock::time_point &  timepoint)

Definition at line 18 of file timestamp.cpp.

◆ MakeDesignEtag()

std::string Utils::MakeDesignEtag ( const std::string &  designsDir,
const std::string &  designName,
const std::string &  endpointPath,
std::uint64_t  generation = 0 
)
inline

Definition at line 120 of file ETag.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeEtag()

std::string Utils::MakeEtag ( const std::string &  designName,
std::int64_t  mtimeTicks,
std::uint64_t  sizeBytes,
const std::string &  endpointPath,
std::uint64_t  generation = 0 
)
inline

Definition at line 53 of file ETag.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_file() [1/2]

void Utils::move_file ( const path &  source,
const path &  dest,
bool  overwriteExisting,
std::error_code &  ec 
)

Definition at line 9 of file fastmove.cpp.

Here is the caller graph for this function:

◆ move_file() [2/2]

UTILS_EXPORT void Utils::move_file ( const std::filesystem::path &  source,
const std::filesystem::path &  dest,
bool  overwriteExisting,
std::error_code &  ec 
)

◆ parse_timestamp()

std::chrono::system_clock::time_point UTILS_EXPORT Utils::parse_timestamp ( const std::string &  timestamp,
const std::string &  format 
)

Definition at line 44 of file timestamp.cpp.

Here is the caller graph for this function:

◆ run_process()

std::int64_t Utils::run_process ( const std::string &  program,
const std::vector< std::string > &  args,
bool  discardOutput 
)

Definition at line 23 of file ProcessSpawn.cpp.

◆ str_iequals()

UTILS_EXPORT bool Utils::str_iequals ( const std::string &  s1,
const std::string &  s2 
)

Definition at line 135 of file str_utils.cpp.

◆ str_ltrim() [1/2]

UTILS_EXPORT std::string & Utils::str_ltrim ( std::string &  s)

std::isspace(char) can only handle chars in the range [0,255] so we need to cast the it's argument to unsigned char

Definition at line 16 of file str_utils.cpp.

Here is the caller graph for this function:

◆ str_ltrim() [2/2]

UTILS_EXPORT std::string & Utils::str_ltrim ( std::string &  s,
char  toRemove 
)

Definition at line 43 of file str_utils.cpp.

◆ str_ltrim_copy() [1/2]

UTILS_EXPORT std::string Utils::str_ltrim_copy ( const std::string &  s)

Definition at line 71 of file str_utils.cpp.

Here is the call graph for this function:

◆ str_ltrim_copy() [2/2]

UTILS_EXPORT std::string Utils::str_ltrim_copy ( const std::string &  s,
char  toRemove 
)

Definition at line 91 of file str_utils.cpp.

Here is the call graph for this function:

◆ str_rtrim() [1/2]

UTILS_EXPORT std::string & Utils::str_rtrim ( std::string &  s)

Definition at line 27 of file str_utils.cpp.

Here is the caller graph for this function:

◆ str_rtrim() [2/2]

UTILS_EXPORT std::string & Utils::str_rtrim ( std::string &  s,
char  toRemove 
)

Definition at line 54 of file str_utils.cpp.

◆ str_rtrim_copy() [1/2]

UTILS_EXPORT std::string Utils::str_rtrim_copy ( const std::string &  s)

Definition at line 78 of file str_utils.cpp.

Here is the call graph for this function:

◆ str_rtrim_copy() [2/2]

UTILS_EXPORT std::string Utils::str_rtrim_copy ( const std::string &  s,
char  toRemove 
)

Definition at line 98 of file str_utils.cpp.

Here is the call graph for this function:

◆ str_to_lower()

UTILS_EXPORT void Utils::str_to_lower ( std::string &  s)

Definition at line 111 of file str_utils.cpp.

◆ str_to_lower_copy()

UTILS_EXPORT std::string Utils::str_to_lower_copy ( const std::string &  s)

Definition at line 121 of file str_utils.cpp.

◆ str_to_upper()

UTILS_EXPORT void Utils::str_to_upper ( std::string &  s)

Definition at line 116 of file str_utils.cpp.

◆ str_to_upper_copy()

UTILS_EXPORT std::string Utils::str_to_upper_copy ( const std::string &  s)

Definition at line 128 of file str_utils.cpp.

◆ str_trim() [1/2]

UTILS_EXPORT std::string & Utils::str_trim ( std::string &  s)

Definition at line 38 of file str_utils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_trim() [2/2]

UTILS_EXPORT std::string & Utils::str_trim ( std::string &  s,
char  toRemove 
)

Definition at line 65 of file str_utils.cpp.

Here is the call graph for this function:

◆ str_trim_copy() [1/2]

UTILS_EXPORT std::string Utils::str_trim_copy ( const std::string &  s)

Definition at line 85 of file str_utils.cpp.

Here is the call graph for this function:

◆ str_trim_copy() [2/2]

UTILS_EXPORT std::string Utils::str_trim_copy ( const std::string &  s,
char  toRemove 
)

Definition at line 105 of file str_utils.cpp.

Here is the call graph for this function:

Variable Documentation

◆ FNV1A64_OFFSET_BASIS

constexpr std::uint64_t Utils::FNV1A64_OFFSET_BASIS = 14695981039346656037ull
inlineconstexpr

Definition at line 32 of file ETag.h.

◆ FNV1A64_PRIME

constexpr std::uint64_t Utils::FNV1A64_PRIME = 1099511628211ull
inlineconstexpr

Definition at line 33 of file ETag.h.

◆ localtimeMutex

std::mutex Utils::localtimeMutex

Definition at line 14 of file CrossPlatform.cpp.

◆ MS_PER_S

const int Utils::MS_PER_S = 1000

Definition at line 16 of file timestamp.cpp.