Tkrzw
|
Common namespace of Tkrzw. More...
Classes | |
class | AtomicSet |
Thread-safe wrapper of std::set. More... | |
class | BabyDBM |
On-memory database manager implementation based on B+ tree. More... | |
class | CacheDBM |
On-memory database manager implementation with LRU deletion. More... | |
class | DBM |
Interface of database manager. More... | |
class | DoubleLRUCache |
Double-layered LRU cache. More... | |
class | File |
Interface of file operations. More... | |
class | FileIndex |
File secondary index implementation with TreeDBM. More... | |
class | FileReader |
File reader. More... | |
struct | FileStatus |
Status information of a file. More... | |
class | FlatRecord |
Flat record structure in the file. More... | |
class | FlatRecordReader |
Reader of flat records. More... | |
struct | FreeBlock |
Free block structure. More... | |
class | FreeBlockPool |
Registry of free blocks. More... | |
class | HashDBM |
File database manager implementation based on hash table. More... | |
class | HashMutex |
Mutex for a hash table. More... | |
class | HashRecord |
Key and value record structure in the file hash database. More... | |
class | LinkedHashMap |
Doubly-linked hash map. More... | |
class | LRUCache |
LRU cache. More... | |
class | MemIndex |
On-memory secondary index implementation with BabyDBM. More... | |
class | MemoryMapAtomicFile |
File implementation with memory mapping and locking for atomic operations. More... | |
class | MemoryMapParallelFile |
File implementation with memory mapping and locking for parallel operations. More... | |
class | OffsetReader |
Reader of a sequence of offsets. More... | |
class | ParamDBM |
Parametric database manager interface. More... | |
class | PolyDBM |
Polymorphic database manager adapter. More... | |
class | PositionalAtomicFile |
File implementation by positional access and locking for atomic operations. More... | |
class | PositionalParallelFile |
File implementation with positional access and locking for parallel operations. More... | |
class | RecordSorter |
Sorter for a large amound of records based on merge sort on files. More... | |
class | ScopedHashLock |
Scoped lock with a mutex for a hash table. More... | |
class | ScopedSlottedLock |
Scoped lock with a slotted shared mutex. More... | |
class | ShardDBM |
Sharding database manager adapter. More... | |
class | SkipDBM |
File database manager implementation based on skip list. More... | |
class | SkipRecord |
Key and value record structure in the file skip database. More... | |
class | SkipRecordCache |
Cache of skip records. More... | |
class | SlottedMutex |
Slotted shared mutex. More... | |
class | Status |
Status of operations. More... | |
class | StatusException |
Exception to convey the status of operations. More... | |
class | StdHashDBM |
On-memory database manager implemented with std::unordered_map. More... | |
class | StdIndex |
On-memory secondary index implementation with std::map for generic types. More... | |
class | StdIndexStr |
On-memory secondary index implementation with std::map for strings. More... | |
class | StdTreeDBM |
On-memory database manager implemented with std::map. More... | |
class | TemporaryDirectory |
Temporary directory whose life duration is bound with the object. More... | |
class | TinyDBM |
On-memory database manager implementation based on hash table. More... | |
class | TreeDBM |
File database manager implementation based on B+ tree. More... | |
struct | TreeLink |
Link to a child node. More... | |
struct | TreeLinkComparator |
Comparator for TreeLink objects. More... | |
struct | TreeLinkOnStack |
Holder of TreeLink on stack for search. More... | |
struct | TreeRecord |
Key and value record structure in the file tree database. More... | |
struct | TreeRecordComparator |
Comparator for TreeRecord objects. More... | |
struct | TreeRecordOnStack |
Holder of TreeRecord on stack for search. More... | |
Typedefs | |
typedef int32_t(* | KeyComparator) (std::string_view, std::string_view) |
Interfrace of comparator of record keys. More... | |
Functions | |
void | Print () |
Prints an empty string to the stdout and flush the buffer. More... | |
template<typename FIRST , typename... REST> | |
void | Print (const FIRST &first, const REST &... rest) |
Prints strings to the stdout and flush the buffer. More... | |
void | PrintL () |
Prints an empty string and a line feed to the stdout and flush the buffer. More... | |
template<typename FIRST , typename... REST> | |
void | PrintL (const FIRST &first, const REST &... rest) |
Prints strings and a line feed to the stdout and flush the buffer. More... | |
void | PrintF (const char *format,...) |
Prints a formatted string to the stdout and flush the buffer. More... | |
void | PutChar (char c) |
Prints a character to the stdout and flush the buffer. More... | |
void | EPrint () |
Prints an empty string to the stderr and flush the buffer. More... | |
template<typename FIRST , typename... REST> | |
void | EPrint (const FIRST &first, const REST &... rest) |
Prints strings to the stderr and flush the buffer. More... | |
void | EPrintL () |
Prints an empty string and a line feed to the stderr and flush the buffer. More... | |
template<typename FIRST , typename... REST> | |
void | EPrintL (const FIRST &first, const REST &... rest) |
Prints strings and a line feed to the stderr and flush the buffer. More... | |
void | EPrintF (const char *format,...) |
Prints a formatted string to the stderr and flush the buffer. More... | |
void | EPutChar (char c) |
Prints a character to the stderr and flush the buffer. More... | |
bool | ParseCommandArguments (int32_t argc, const char **argv, const std::map< std::string, int32_t > &configs, std::map< std::string, std::vector< std::string >> *result, std::string *error_message) |
Parses command line arguments. More... | |
std::string | GetStringArgument (const std::map< std::string, std::vector< std::string >> &args, const std::string &name, int32_t index, const std::string &default_value) |
Gets a string argument of parsed command arguments. More... | |
int64_t | GetIntegerArgument (const std::map< std::string, std::vector< std::string >> &args, const std::string &name, int32_t index, int64_t default_value) |
Gets an integer argument of parsed command arguments. More... | |
double | GetDoubleArgument (const std::map< std::string, std::vector< std::string >> &args, const std::string &name, int32_t index, double default_value) |
Gets a real number argument of parsed command arguments. More... | |
std::map< std::string, std::string > | GetSystemInfo () |
Gets system information of the environment. More... | |
void | Die (const std::string &message) |
Throws an exception of StatusException to terminates the process with a message. More... | |
template<typename FIRST , typename... REST> | |
void | Die (const FIRST &first, const REST &... rest) |
Throws an exception of StatusException to terminates the process with a message. More... | |
std::unique_ptr< File > | MakeFileOrDie (const std::string &impl_name, int64_t alloc_init_size, double alloc_inc_factor) |
Makes a file object or die. More... | |
void | LockMemoryOfFileOrDie (File *file, size_t size) |
Locks the memory of the beginning region or die. More... | |
void | PrintDBMRecordsInTSV (DBM *dbm) |
Prints all records of a DBM in TSV format. More... | |
template<typename C , typename T > | |
void | HeapByCostAdd (const C &cost, const T &payload, size_t capacity, std::vector< std::pair< C, T >> *heap) |
Adds a pair of a cont and a payload to a heap vector. More... | |
template<typename C , typename T > | |
void | HeapByCostFinish (std::vector< std::pair< C, T >> *heap) |
Finishes a heap vector to be in sorted order. More... | |
uint64_t | PrimaryHash (std::string_view data, uint64_t num_buckets) |
Primary hash function for the hash database. More... | |
uint64_t | SecondaryHash (std::string_view data, uint64_t num_shards) |
Secondary hash function for sharding. More... | |
uint64_t | IsPrimeNumber (uint64_t num) |
Returns true if an integer is a prime number. More... | |
int64_t | GetHashBucketSize (int64_t min_size) |
Gets a proper bucket size for hashing. More... | |
Status | SearchDBM (DBM *dbm, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0, bool(*matcher)(std::string_view, std::string_view)=StrContains) |
Searches a database and get keys which match a pattern. More... | |
Status | SearchDBMForwardMatch (DBM *dbm, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0) |
Searches a database and get keys which begin with a pattern. More... | |
Status | SearchDBMRegex (DBM *dbm, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0, bool utf=false) |
Searches a database and get keys which match a regular expression. More... | |
Status | SearchDBMEditDistance (DBM *dbm, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0, bool utf=false) |
Searches a database and get keys whose edit distance with a pattern is the least. More... | |
Status | ExportDBMRecordsToFlatRecords (DBM *dbm, File *file) |
Exports all records of a database to a flat record file. More... | |
Status | ImportDBMRecordsFromFlatRecords (DBM *dbm, File *file) |
Imports records to a database from a flat record file. More... | |
Status | ExportDBMKeysToFlatRecords (DBM *dbm, File *file) |
Exports the keys of all records of a database to a flat record file. More... | |
Status | ExportDBMRecordsToTSV (DBM *dbm, File *file, bool escape=false) |
Exports all records of a database to a TSV file. More... | |
Status | ImportDBMRecordsFromTSV (DBM *dbm, File *file, bool unescape=false) |
Imports records to a database from a TSV file. More... | |
Status | ExportDBMKeysAsLines (DBM *dbm, File *file) |
Exports the keys of all records of a database as lines to a text file. More... | |
Status | SearchTextFile (File *file, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0, bool(*matcher)(std::string_view, std::string_view)=StrContains) |
Searches a text file and get lines which match a pattern. More... | |
Status | SearchTextFileRegex (File *file, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0, bool utf=false) |
Searches a text file and get lines which match a regular expression. More... | |
Status | SearchTextFileEditDistance (File *file, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0, bool utf=false) |
Searches a text file and get lines whose edit distance with a pattern is the least. More... | |
TreeRecord * | CreateTreeRecord (std::string_view key, std::string_view value) |
Creates a tree record. More... | |
TreeRecord * | ModifyTreeRecord (TreeRecord *record, std::string_view new_value) |
Modifies the value of a tree record. More... | |
void | FreeTreeRecord (TreeRecord *record) |
Frees the region of a tree record. More... | |
void | FreeTreeRecords (std::vector< TreeRecord *> *records) |
Frees the regions of tree records. More... | |
TreeLink * | CreateTreeLink (std::string_view key, int64_t child) |
Creates a tree link. More... | |
void | FreeTreeLink (TreeLink *link) |
Frees the region of a tree link. More... | |
void | FreeTreeLinks (std::vector< TreeLink *> *links) |
Frees the regions of tree links. More... | |
std::string | MakeTemporaryName () |
Makes a unique name for a temporary file. More... | |
std::string | JoinPath (const std::string &base_path, const std::string &child_name) |
Joins a base path and a child name. More... | |
std::string | NormalizePath (const std::string &path) |
Normalizes a file path. More... | |
std::string | PathToBaseName (const std::string &path) |
Gets the base name part of a path. More... | |
std::string | PathToDirectoryName (const std::string &path) |
Gets the directory name part of a path. More... | |
std::string | PathToExtension (const std::string &path) |
Gets the extention part of a path. More... | |
Status | GetRealPath (const std::string &path, std::string *real_path) |
Gets the normalized and canonical form of a path. More... | |
Status | ReadFileStatus (const std::string &path, FileStatus *fstats) |
Reads status information of a file. More... | |
bool | PathIsFile (const std::string &path) |
Checks if a path indicates a regular file. More... | |
int64_t | GetFileSize (const std::string &path) |
Gets the size of a file. More... | |
bool | PathIsDirectory (const std::string &path) |
Checks if a path indicates a directory. More... | |
std::string | GetPathToTemporaryDirectory () |
Gets the path to a directory for temporary files. More... | |
Status | WriteFile (const std::string &path, std::string_view content) |
Write a file with a content. More... | |
Status | ReadFile (const std::string &path, std::string *content) |
Read the content from a file. More... | |
Status | RemoveFile (const std::string &path) |
Removes a file. More... | |
Status | RenameFile (const std::string &src_path, const std::string &dest_path) |
Renames a file. More... | |
Status | CopyFile (const std::string &src_path, const std::string &dest_path) |
Copies a file. More... | |
Status | ReadDirectory (const std::string &path, std::vector< std::string > *children) |
Reads a directory. More... | |
Status | MakeDirectory (const std::string &path, bool recursive=false) |
Makes a directory. More... | |
Status | RemoveDirectory (const std::string &path, bool recursive=false) |
Removes a directory. More... | |
int32_t | LexicalKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the lexical order. More... | |
int32_t | LexicalCaseKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the lexical order ignoring case. More... | |
int32_t | DecimalKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the order of the decimal integer numeric expressions. More... | |
int32_t | HexadecimalKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the order of the hexadecimal integer numeric expressions. More... | |
int32_t | RealNumberKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the order of the decimal real number expressions. More... | |
int32_t | PairLexicalKeyComparator (std::string_view a, std::string_view b) |
Key comparator for serialized pair strings in the lexical order. More... | |
int32_t | PairLexicalCaseKeyComparator (std::string_view a, std::string_view b) |
Key comparator for serialized pair strings in the lexical order ignoring case. More... | |
int32_t | PairDecimalKeyComparator (std::string_view a, std::string_view b) |
Key comparator for serialized pair strings in the decimal integer order. More... | |
int32_t | PairHexadecimalKeyComparator (std::string_view a, std::string_view b) |
Key comparator for serialized pair strings in the hexadecimal integer order. More... | |
int32_t | PairRealNumberKeyComparator (std::string_view a, std::string_view b) |
Key comparator for serialized pair strings in the decimal real number order. More... | |
bool | operator== (const Status::Code &lhs, const Status &rhs) |
Checks whether a stauts code is equal to another status object. More... | |
bool | operator!= (const Status::Code &lhs, const Status &rhs) |
Checks whether a stauts code is not equal to another status object. More... | |
std::string | ToString (const Status &status) |
Converts a status into a string. More... | |
std::ostream & | operator<< (std::ostream &os, const Status &status) |
Outputs a status string into an output stream. More... | |
void * | xmalloc (size_t size) |
Allocates a region on memory. More... | |
void * | xcalloc (size_t nmemb, size_t size) |
Allocates a nullified region on memory. More... | |
void * | xrealloc (void *ptr, size_t size) |
Re-allocates a region on memory. More... | |
void * | xreallocappend (void *ptr, size_t size) |
Re-allocates a region on memory for appending operations. More... | |
void | xfree (void *ptr) |
Frees a region on memory. More... | |
template<typename SET > | |
bool | CheckSet (SET set, const typename SET::key_type &elem) |
Checks whether a set has an element. More... | |
template<typename MAP > | |
bool | CheckMap (MAP map, const typename MAP::key_type &key) |
Checks whether a map has a key. More... | |
template<typename MAP > | |
MAP::value_type::first_type | SearchMap (MAP map, const typename MAP::key_type &key, const typename MAP::value_type::second_type &default_value) |
Searches a map and get the value of a record. More... | |
uint64_t | HashMurmur (const void *buf, size_t size, uint64_t seed) |
Gets the hash value by Murmur hashing. More... | |
uint64_t | HashMurmur (std::string_view str, uint64_t seed) |
Gets the hash value by Murmur hashing. More... | |
uint64_t | HashFNV (const void *buf, size_t size) |
Gets the hash value by FNV hashing. More... | |
uint64_t | HashFNV (std::string_view str) |
Gets the hash value by FNV hashing. More... | |
uint32_t | HashCRC32Continuous (const void *buf, size_t size, bool finish, uint32_t seed=0xFFFFFFFF) |
Gets the hash value by CRC-32, in a continuous way. More... | |
uint32_t | HashCRC32 (const void *buf, size_t size) |
Gets the hash value by CRC-32. More... | |
uint32_t | HashCRC32 (const std::string &str) |
Gets the hash value by CRC-32. More... | |
uint64_t | MakeRandomInt () |
Makes a random integer from a hidden seed. More... | |
double | MakeRandomDouble () |
Makes a random real number from a hidden seed. More... | |
Status | GetErrnoStatus (const char *call_name, int32_t sys_err_num) |
Gets a status according to a system error number of a system call. More... | |
int64_t | StrToInt (std::string_view str, int64_t defval=0) |
Converts a decimal string to an integer. More... | |
int64_t | StrToIntMetric (std::string_view str, int64_t defval=0) |
Converts a decimal string with a metric prefix to an integer. More... | |
uint64_t | StrToIntOct (std::string_view str, uint64_t defval=0) |
Converts a octal string to an integer. More... | |
uint64_t | StrToIntHex (std::string_view str, uint64_t defval=0) |
Converts a hexadecimal string to an integer. More... | |
uint64_t | StrToIntBigEndian (std::string_view str) |
Converts a big-endian binary string to an integer. More... | |
double | StrToDouble (std::string_view str, double defval=0.0) |
Converts a decimal string to a real number. More... | |
bool | StrToBool (std::string_view str, bool defval=false) |
Converts a boolean string to a real number. More... | |
void | VSPrintF (std::string *dest, const char *format, va_list ap) |
Appends a formatted string at the end of a string. More... | |
void | SPrintF (std::string *dest, const char *format,...) |
Appends a formatted string at the end of a string. More... | |
std::string | SPrintF (const char *format,...) |
Generates a formatted string. More... | |
template<typename T > | |
std::string | ToString (T data) |
Converts an integer to a decimal string. More... | |
std::string | ToString (double data) |
Converts a real number to a decimal string. More... | |
std::string | ToString (float data) |
Converts a real number to a decimal string. More... | |
std::string | ToString (long double data) |
Converts a real number to a decimal string. More... | |
std::string | ToString (bool data) |
Converts a boolean value to a decimal string. More... | |
std::string | ToString (char data) |
Converts a character into a string. More... | |
std::string | ToString (const char *data) |
Converts a C-style string into a string. More... | |
std::string | ToString (std::string_view data) |
Converts a string view into a string. More... | |
std::string | ToString (const std::string &data) |
Copies a string. More... | |
std::string | IntToStrBigEndian (uint64_t data, size_t size=sizeof(uint64_t)) |
Converts an integer into a big-endian binary string. More... | |
template<typename T > | |
std::string | StrJoin (const T &elems, const std::string_view &delim) |
Converts each record of a container into strings and join them. More... | |
std::string | StrCat () |
Returns an empty string. More... | |
template<typename FIRST , typename... REST> | |
std::string | StrCat (const FIRST &first, const REST &... rest) |
Concatenates data of arbitrary parameters into a string. More... | |
std::vector< std::string > | StrSplit (std::string_view str, char delim, bool skip_empty=false) |
Splits a string with a delimiter character. More... | |
std::vector< std::string > | StrSplit (std::string_view str, std::string_view delim, bool skip_empty=false) |
Splits a string with a delimiter string. More... | |
std::vector< std::string > | StrSplitAny (std::string_view str, std::string_view delims, bool skip_empty=false) |
Splits a string with delimiter characters. More... | |
std::map< std::string, std::string > | StrSplitIntoMap (std::string_view str, std::string_view delim_records, std::string_view delim_kv) |
Splits a string into a key-value map. More... | |
std::string | StrUpperCase (std::string_view str) |
Converts letters of a string into upper case. More... | |
std::string | StrLowerCase (std::string_view str) |
Converts letters of a string into lower case. More... | |
bool | StrContains (std::string_view text, std::string_view pattern) |
Checks whether a text contains a pattern. More... | |
bool | StrBeginsWith (std::string_view text, std::string_view pattern) |
Checks whether a text begins with a pattern. More... | |
bool | StrEndsWith (std::string_view text, std::string_view pattern) |
Checks whether a text ends with a pattern. More... | |
int32_t | StrCaseCompare (std::string_view a, std::string_view b) |
Compares two strings ignoring case. More... | |
int32_t | StrSearch (std::string_view text, std::string_view pattern) |
Searches a text for a pattern, with string::find. More... | |
int32_t | StrSearchDoubleLoop (std::string_view text, std::string_view pattern) |
Searches a text for a pattern, by naive double loop. More... | |
int32_t | StrSearchMemchr (std::string_view text, std::string_view pattern) |
Searches a text for a pattern, with memchr. More... | |
int32_t | StrSearchMemmem (std::string_view text, std::string_view pattern) |
Searches a text for a pattern, with memmem. More... | |
int32_t | StrSearchKMP (std::string_view text, std::string_view pattern) |
Searches a text for a pattern, by Knuth–Morris–Pratt algorithm. More... | |
int32_t | StrSearchBM (std::string_view text, std::string_view pattern) |
Searches a text for a pattern, by Boyer-Moore algorithm. More... | |
int32_t | StrSearchRK (std::string_view text, std::string_view pattern) |
Searches a text for a pattern, by Rabin-Karp algorithm. More... | |
int32_t | StrSearchZ (std::string_view text, std::string_view pattern) |
Searches a text for a pattern, by Z algorithm. More... | |
std::vector< int32_t > | StrSearchWhole (std::string_view text, std::string_view pattern, size_t max_results=0) |
Searches a text for a pattern and get indices of all occurrences, with string::find. More... | |
std::vector< int32_t > | StrSearchWholeKMP (std::string_view text, std::string_view pattern, size_t max_results=0) |
Searches a text for a pattern and get indices of all occurrences, by KMP algorithm. More... | |
std::vector< int32_t > | StrSearchWholeBM (std::string_view text, std::string_view pattern, size_t max_results=0) |
Searches a text for a pattern and get indices of all occurrences, by BM algorithm. More... | |
std::vector< int32_t > | StrSearchWholeRK (std::string_view text, std::string_view pattern, size_t max_results=0) |
Searches a text for a pattern and get indices of all occurrences, by RK algorithm. More... | |
std::vector< std::vector< int32_t > > | StrSearchBatch (std::string_view text, const std::vector< std::string > &patterns, size_t max_results=0) |
Searches a text for patterns and get indices of all occurrences, by string::find. More... | |
std::vector< std::vector< int32_t > > | StrSearchBatchKMP (std::string_view text, const std::vector< std::string > &patterns, size_t max_results=0) |
Searches a text for patterns and get indices of all occurrences, by KMP algorithm. More... | |
std::vector< std::vector< int32_t > > | StrSearchBatchBM (std::string_view text, const std::vector< std::string > &patterns, size_t max_results=0) |
Searches a text for patterns and get indices of all occurrences, by BM algorithm. More... | |
std::vector< std::vector< int32_t > > | StrSearchBatchRK (std::string_view text, const std::vector< std::string > &patterns, size_t max_results=0) |
Searches a text for patterns and get indices of all occurrences, by RK algorithm. More... | |
std::string | StrStripSpace (std::string_view str) |
Removes space characters at the head or the tail of a string. More... | |
std::string | StrStripLine (std::string_view str) |
Removes linefeed characters from the end of a string. More... | |
std::string | StrSqueezeAndStripSpace (std::string_view str) |
Squeezes space characters in a string and removes spaces at both ends. More... | |
std::string | StrTrimForTSV (std::string_view str) |
Trims a string for TSV by normalizing space and control characters. More... | |
std::string | StrEscapeC (std::string_view str, bool esc_nonasc=false) |
Escapes C-style meta characters in a string. More... | |
std::string | StrUnescapeC (std::string_view str) |
Unescapes C-style escape sequences in a string. More... | |
std::string | StrEncodeBase64 (std::string_view str) |
Encodes a string into a Base64 string. More... | |
std::string | StrDecodeBase64 (std::string_view str) |
Decodes a Base64 string into a string. More... | |
std::string | StrEncodeURL (std::string_view str) |
Encodes a string into a URL part string. More... | |
std::string | StrDecodeURL (std::string_view str) |
Decodes a URL part string into a string. More... | |
std::vector< uint32_t > | ConvertUTF8ToUCS4 (std::string_view utf) |
Converts a UTF-8 string into a UCS-4 vector. More... | |
std::string | ConvertUCS4ToUTF8 (const std::vector< uint32_t > &ucs) |
Converts a UCS-4 vector into a UTF-8 string. More... | |
std::wstring | ConvertUTF8ToWide (std::string_view utf) |
Converts a UTF-8 string into a wide string. More... | |
std::string | ConvertWideToUTF8 (const std::wstring &wstr) |
Converts a wide string into a UTF-8 string. More... | |
std::string | MakeRandomCharacterText (int32_t length, uint8_t first_char, uint8_t last_char) |
Makes a text composed of characters selected at random. More... | |
std::string | SerializeStrPair (std::string_view first, std::string_view second) |
Serializes a pair of strings into a string. More... | |
void | DeserializeStrPair (std::string_view serialized, std::string_view *first, std::string_view *second) |
Deserializes a serialized string into a pair of strings. More... | |
std::string_view | GetFirstFromSerializedStrPair (std::string_view serialized) |
Get the first part from a serialized string pair. More... | |
std::string | SerializeStrVector (const std::vector< std::string > &values) |
Serializes a vector of strings into a string. More... | |
std::vector< std::string > | DeserializeStrVector (std::string_view serialized) |
Deserializes a serialized string into a string vector. More... | |
std::string | SerializeStrMap (const std::map< std::string, std::string > &records) |
Serializes a map of strings into a string. More... | |
std::map< std::string, std::string > | DeserializeStrMap (std::string_view serialized) |
Deserializes a serialized string into a string map. More... | |
double | GetWallTime () |
Gets the number of seconds since the UNIX epoch. More... | |
void | Sleep (double sec) |
Sleeps the current thread. More... | |
Variables | |
constexpr int8_t | INT8MIN = std::numeric_limits<int8_t>::min() |
The minimum value of int8_t. More... | |
constexpr int8_t | INT8MAX = std::numeric_limits<int8_t>::max() |
The maximum value of int8_t. More... | |
constexpr uint8_t | UINT8MAX = std::numeric_limits<uint8_t>::max() |
The maximum value of uint8_t. More... | |
constexpr int16_t | INT16MIN = std::numeric_limits<int16_t>::min() |
The minimum value of int16_t. More... | |
constexpr int16_t | INT16MAX = std::numeric_limits<int16_t>::max() |
The maximum value of int16_t. More... | |
constexpr uint16_t | UINT16MAX = std::numeric_limits<uint16_t>::max() |
The maximum value of uint16_t. More... | |
constexpr int32_t | INT32MIN = std::numeric_limits<int32_t>::min() |
The minimum value of int32_t. More... | |
constexpr int32_t | INT32MAX = std::numeric_limits<int32_t>::max() |
The maximum value of int32_t. More... | |
constexpr uint32_t | UINT32MAX = std::numeric_limits<uint32_t>::max() |
The maximum value of uint32_t. More... | |
constexpr int64_t | INT64MIN = std::numeric_limits<int64_t>::min() |
The minimum value of int64_t. More... | |
constexpr int64_t | INT64MAX = std::numeric_limits<int64_t>::max() |
The maximum value of int64_t. More... | |
constexpr uint64_t | UINT64MAX = std::numeric_limits<uint64_t>::max() |
The maximum value of uint64_t. More... | |
constexpr size_t | SIZEMAX = std::numeric_limits<size_t>::max() |
The maximum value of size_t. More... | |
constexpr float | FLOATMIN = std::numeric_limits<float>::min() |
The minimum value of float. More... | |
constexpr float | FLOATMAX = std::numeric_limits<float>::max() |
The maximum value of float. More... | |
constexpr double | DOUBLEMIN = std::numeric_limits<double>::min() |
The minimum value of double. More... | |
constexpr double | DOUBLEMAX = std::numeric_limits<double>::max() |
The maximum value of double. More... | |
constexpr double | DOUBLENAN = std::numeric_limits<double>::quiet_NaN() |
The quiet Not-a-Number value of double. More... | |
constexpr double | DOUBLEINF = std::numeric_limits<double>::infinity() |
The positive infinity value of double. More... | |
constexpr int32_t | NUM_BUFFER_SIZE = 32 |
The buffer size for a numeric string expression. More... | |
constexpr int64_t | MAX_MEMORY_SIZE = (1LL << 40) |
The maximum memory size. More... | |
const int32_t | PAGE_SIZE |
The size of a memory page on the OS. More... | |
const char *const | PACKAGE_VERSION |
The string expression of the package version. More... | |
const char *const | LIBRARY_VERSION |
The string expression of the library version. More... | |
const char *const | OS_NAME |
The recognized OS name. More... | |
const bool | IS_BIG_ENDIAN |
True if the byte order is big endian. More... | |
Common namespace of Tkrzw.
typedef int32_t(* tkrzw::KeyComparator) (std::string_view, std::string_view) |
Interfrace of comparator of record keys.
The fucntion returns -1 if the first parameter is less, 1 if the first parameter is greater, and 0 if both are equivalent.
void tkrzw::Print | ( | ) |
Prints an empty string to the stdout and flush the buffer.
void tkrzw::Print | ( | const FIRST & | first, |
const REST &... | rest | ||
) |
Prints strings to the stdout and flush the buffer.
first | The first string. |
rest | The rest strings. |
void tkrzw::PrintL | ( | ) |
Prints an empty string and a line feed to the stdout and flush the buffer.
void tkrzw::PrintL | ( | const FIRST & | first, |
const REST &... | rest | ||
) |
Prints strings and a line feed to the stdout and flush the buffer.
first | The first string. |
rest | The rest strings. |
void tkrzw::PrintF | ( | const char * | format, |
... | |||
) |
Prints a formatted string to the stdout and flush the buffer.
format | The format string. |
... | The other arguments. |
void tkrzw::PutChar | ( | char | c | ) |
Prints a character to the stdout and flush the buffer.
c | The character to print. |
void tkrzw::EPrint | ( | ) |
Prints an empty string to the stderr and flush the buffer.
void tkrzw::EPrint | ( | const FIRST & | first, |
const REST &... | rest | ||
) |
Prints strings to the stderr and flush the buffer.
first | The first string. |
rest | The rest strings. |
void tkrzw::EPrintL | ( | ) |
Prints an empty string and a line feed to the stderr and flush the buffer.
void tkrzw::EPrintL | ( | const FIRST & | first, |
const REST &... | rest | ||
) |
Prints strings and a line feed to the stderr and flush the buffer.
first | The first string. |
rest | The rest strings. |
void tkrzw::EPrintF | ( | const char * | format, |
... | |||
) |
Prints a formatted string to the stderr and flush the buffer.
format | The format string. |
... | The other arguments. |
void tkrzw::EPutChar | ( | char | c | ) |
Prints a character to the stderr and flush the buffer.
c | The character to print. |
bool tkrzw::ParseCommandArguments | ( | int32_t | argc, |
const char ** | argv, | ||
const std::map< std::string, int32_t > & | configs, | ||
std::map< std::string, std::vector< std::string >> * | result, | ||
std::string * | error_message | ||
) |
Parses command line arguments.
argc | The number of input arguments. |
argv | The input arguments. |
configs | A map of option names and numbers of the required arguments. If an empty string represents positional arguments. |
result | The pointer to a map object to contain option names and their arguments. |
error_message | The pointer to a string object to contain the error message. |
std::string tkrzw::GetStringArgument | ( | const std::map< std::string, std::vector< std::string >> & | args, |
const std::string & | name, | ||
int32_t | index, | ||
const std::string & | default_value | ||
) |
Gets a string argument of parsed command arguments.
args | The parsed command arguments. |
name | The name of the argument. |
index | The index of the value. |
default_value | The value to be returned on failure. |
int64_t tkrzw::GetIntegerArgument | ( | const std::map< std::string, std::vector< std::string >> & | args, |
const std::string & | name, | ||
int32_t | index, | ||
int64_t | default_value | ||
) |
Gets an integer argument of parsed command arguments.
args | The parsed command arguments. |
name | The name of the argument. |
index | The index of the value. |
default_value | The value to be returned on failure. |
double tkrzw::GetDoubleArgument | ( | const std::map< std::string, std::vector< std::string >> & | args, |
const std::string & | name, | ||
int32_t | index, | ||
double | default_value | ||
) |
Gets a real number argument of parsed command arguments.
args | The parsed command arguments. |
name | The name of the argument. |
index | The index of the value. |
default_value | The value to be returned on failure. |
std::map<std::string, std::string> tkrzw::GetSystemInfo | ( | ) |
Gets system information of the environment.
void tkrzw::Die | ( | const std::string & | message | ) |
Throws an exception of StatusException to terminates the process with a message.
message | The message to print. |
void tkrzw::Die | ( | const FIRST & | first, |
const REST &... | rest | ||
) |
Throws an exception of StatusException to terminates the process with a message.
first | The first parameter. |
rest | The rest parameters. |
std::unique_ptr<File> tkrzw::MakeFileOrDie | ( | const std::string & | impl_name, |
int64_t | alloc_init_size, | ||
double | alloc_inc_factor | ||
) |
Makes a file object or die.
impl_name | The name of a File implementation: "mmap-para" for MemoryMapParallelFile, "mmap-atom" for MemoryMapAtomicFile, "pos-para" for PositionalParallelFile. "pos-atom" fo PositionalAtomicFile, |
alloc_init_size | An initial size of allocation. |
alloc_inc_factor | A factor to increase the size of allocation. |
void tkrzw::LockMemoryOfFileOrDie | ( | File * | file, |
size_t | size | ||
) |
Locks the memory of the beginning region or die.
file | The file object. |
size | The size of the beginning region to lock. |
If the operation is not supported, this does nothing.
void tkrzw::PrintDBMRecordsInTSV | ( | DBM * | dbm | ) |
void tkrzw::HeapByCostAdd | ( | const C & | cost, |
const T & | payload, | ||
size_t | capacity, | ||
std::vector< std::pair< C, T >> * | heap | ||
) |
Adds a pair of a cont and a payload to a heap vector.
cost | The cost. |
payload | The payload. |
capacity | The capacity of the heap vector. |
heap | The pointer to the heap vector. |
void tkrzw::HeapByCostFinish | ( | std::vector< std::pair< C, T >> * | heap | ) |
Finishes a heap vector to be in sorted order.
heap | The heap vector. |
uint64_t tkrzw::PrimaryHash | ( | std::string_view | data, |
uint64_t | num_buckets | ||
) |
Primary hash function for the hash database.
data | The data to calculate the hash value for. |
num_buckets | The number of buckets of the hash table. |
uint64_t tkrzw::SecondaryHash | ( | std::string_view | data, |
uint64_t | num_shards | ||
) |
Secondary hash function for sharding.
data | The data to calculate the hash value for. |
num_shards | The number of shards. |
uint64_t tkrzw::IsPrimeNumber | ( | uint64_t | num | ) |
Returns true if an integer is a prime number.
num | The integer. |
int64_t tkrzw::GetHashBucketSize | ( | int64_t | min_size | ) |
Gets a proper bucket size for hashing.
min_size | The minimum size. |
Status tkrzw::SearchDBM | ( | DBM * | dbm, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 , |
||
bool(*)(std::string_view, std::string_view) | matcher = StrContains |
||
) |
Searches a database and get keys which match a pattern.
dbm | The DBM object of the database. |
pattern | The pattern for matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
matcher | A matching function which takes the pattern and a candidate. |
This scans the whole database so it can take long time.
Status tkrzw::SearchDBMForwardMatch | ( | DBM * | dbm, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a database and get keys which begin with a pattern.
dbm | The DBM object of the database. |
pattern | The pattern for forward matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
If the database is ordered, an efficient way is used. However, if the key comparator is not LexicalKeyComparator, all matching keys are not extracted. If the database is unordered, this scans the whole database so it can take long time.
Status tkrzw::SearchDBMRegex | ( | DBM * | dbm, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 , |
||
bool | utf = false |
||
) |
Searches a database and get keys which match a regular expression.
dbm | The DBM object of the database. |
pattern | The regular expression pattern for partial matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
utf | If true, text is treated as UTF-8 and matching is done with UCS sequences. |
This scans the whole database so it can take long time.
Status tkrzw::SearchDBMEditDistance | ( | DBM * | dbm, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 , |
||
bool | utf = false |
||
) |
Searches a database and get keys whose edit distance with a pattern is the least.
dbm | The DBM object of the database. |
pattern | The pattern for matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
utf | If true, text is treated as UTF-8 and the distance is calculated between UCS sequences. |
This scans the whole database so it can take long time.
Exports all records of a database to a flat record file.
dbm | The DBM object of the database. |
file | The file object to write records in. |
Imports records to a database from a flat record file.
dbm | The DBM object of the database. |
file | The file object to read records from. |
Exports the keys of all records of a database to a flat record file.
dbm | The DBM object of the database. |
file | The file object to write keys in. |
Exports all records of a database to a TSV file.
dbm | The DBM object of the database. |
file | The file object to write records in. |
escape | If true, C-style escaping is applied to the output. |
Imports records to a database from a TSV file.
dbm | The DBM object of the database. |
file | The file object to read records from. |
unescape | If true, C-style unescaping is applied to the input. |
Exports the keys of all records of a database as lines to a text file.
dbm | The DBM object of the database. |
file | The file object to write keys in. |
Status tkrzw::SearchTextFile | ( | File * | file, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 , |
||
bool(*)(std::string_view, std::string_view) | matcher = StrContains |
||
) |
Searches a text file and get lines which match a pattern.
file | The file to search. |
pattern | The pattern for matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
matcher | A matching function which takes the pattern and a candidate. |
Status tkrzw::SearchTextFileRegex | ( | File * | file, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 , |
||
bool | utf = false |
||
) |
Searches a text file and get lines which match a regular expression.
file | The file to search. |
pattern | The regular expression pattern for partial matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
utf | If true, text is decoded as UTF-8 and edit distance is calculated by the unicode characters. |
Status tkrzw::SearchTextFileEditDistance | ( | File * | file, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 , |
||
bool | utf = false |
||
) |
Searches a text file and get lines whose edit distance with a pattern is the least.
file | The file to search. |
pattern | The pattern for matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
utf | If true, text is decoded as UTF-8 and edit distance is calculated by the unicode characters. |
TreeRecord* tkrzw::CreateTreeRecord | ( | std::string_view | key, |
std::string_view | value | ||
) |
Creates a tree record.
key | The key data. |
value | The value data. |
TreeRecord* tkrzw::ModifyTreeRecord | ( | TreeRecord * | record, |
std::string_view | new_value | ||
) |
Modifies the value of a tree record.
record | The record to modify. |
new_value | The new value data. |
void tkrzw::FreeTreeRecord | ( | TreeRecord * | record | ) |
Frees the region of a tree record.
record | The record to free. |
void tkrzw::FreeTreeRecords | ( | std::vector< TreeRecord *> * | records | ) |
Frees the regions of tree records.
records | A vector of the records to free. |
TreeLink* tkrzw::CreateTreeLink | ( | std::string_view | key, |
int64_t | child | ||
) |
Creates a tree link.
key | The key data. |
child | The page ID of the child node. |
void tkrzw::FreeTreeLink | ( | TreeLink * | link | ) |
Frees the region of a tree link.
link | The link to free. |
void tkrzw::FreeTreeLinks | ( | std::vector< TreeLink *> * | links | ) |
Frees the regions of tree links.
links | A vector of the links to free. |
std::string tkrzw::MakeTemporaryName | ( | ) |
Makes a unique name for a temporary file.
std::string tkrzw::JoinPath | ( | const std::string & | base_path, |
const std::string & | child_name | ||
) |
Joins a base path and a child name.
base_path | The base path. |
child_name | The child name. |
std::string tkrzw::NormalizePath | ( | const std::string & | path | ) |
Normalizes a file path.
path | The path to normalize. |
std::string tkrzw::PathToBaseName | ( | const std::string & | path | ) |
Gets the base name part of a path.
path | The path. |
std::string tkrzw::PathToDirectoryName | ( | const std::string & | path | ) |
Gets the directory name part of a path.
path | The path. |
std::string tkrzw::PathToExtension | ( | const std::string & | path | ) |
Gets the extention part of a path.
path | The path. |
Status tkrzw::GetRealPath | ( | const std::string & | path, |
std::string * | real_path | ||
) |
Gets the normalized and canonical form of a path.
path | The path to check. |
real_path | The pointer to a string object to store the content. |
Status tkrzw::ReadFileStatus | ( | const std::string & | path, |
FileStatus * | fstats | ||
) |
Reads status information of a file.
path | The path to the file. |
fstats | The pointer to a file status object. |
bool tkrzw::PathIsFile | ( | const std::string & | path | ) |
Checks if a path indicates a regular file.
path | The path to check. |
int64_t tkrzw::GetFileSize | ( | const std::string & | path | ) |
Gets the size of a file.
path | The path to the file. |
bool tkrzw::PathIsDirectory | ( | const std::string & | path | ) |
Checks if a path indicates a directory.
path | The path to check. |
std::string tkrzw::GetPathToTemporaryDirectory | ( | ) |
Gets the path to a directory for temporary files.
Status tkrzw::WriteFile | ( | const std::string & | path, |
std::string_view | content | ||
) |
Write a file with a content.
path | The path of the file to write. |
content | The content. |
Status tkrzw::ReadFile | ( | const std::string & | path, |
std::string * | content | ||
) |
Read the content from a file.
path | The path of the file to make. |
content | The pointer to a string object to contain the content. |
Status tkrzw::RemoveFile | ( | const std::string & | path | ) |
Removes a file.
path | The path of the file. |
Status tkrzw::RenameFile | ( | const std::string & | src_path, |
const std::string & | dest_path | ||
) |
Renames a file.
src_path | The source path of the file. |
dest_path | The destination path of the file. |
Status tkrzw::CopyFile | ( | const std::string & | src_path, |
const std::string & | dest_path | ||
) |
Copies a file.
src_path | The source path of the file. |
dest_path | The destination path of the file. |
Status tkrzw::ReadDirectory | ( | const std::string & | path, |
std::vector< std::string > * | children | ||
) |
Reads a directory.
path | The path of the directory. |
children | A vector object to contain the names of all children. |
Status tkrzw::MakeDirectory | ( | const std::string & | path, |
bool | recursive = false |
||
) |
Makes a directory.
path | The path of the directory. |
recursive | If true, parent directories are made recursively. |
Status tkrzw::RemoveDirectory | ( | const std::string & | path, |
bool | recursive = false |
||
) |
Removes a directory.
path | The path of the directory. |
recursive | If true, contents of children are removed recursively. |
int32_t tkrzw::LexicalKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator in the lexical order.
a | One key. |
b | The other key. |
int32_t tkrzw::LexicalCaseKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator in the lexical order ignoring case.
a | One key. |
b | The other key. |
int32_t tkrzw::DecimalKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator in the order of the decimal integer numeric expressions.
a | One key. |
b | The other key. |
int32_t tkrzw::HexadecimalKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator in the order of the hexadecimal integer numeric expressions.
a | One key. |
b | The other key. |
int32_t tkrzw::RealNumberKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator in the order of the decimal real number expressions.
a | One key. |
b | The other key. |
int32_t tkrzw::PairLexicalKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator for serialized pair strings in the lexical order.
a | One key. |
b | The other key. |
int32_t tkrzw::PairLexicalCaseKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator for serialized pair strings in the lexical order ignoring case.
a | One key. |
b | The other key. |
int32_t tkrzw::PairDecimalKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator for serialized pair strings in the decimal integer order.
a | One key. |
b | The other key. |
int32_t tkrzw::PairHexadecimalKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator for serialized pair strings in the hexadecimal integer order.
a | One key. |
b | The other key. |
int32_t tkrzw::PairRealNumberKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator for serialized pair strings in the decimal real number order.
a | One key. |
b | The other key. |
bool tkrzw::operator== | ( | const Status::Code & | lhs, |
const Status & | rhs | ||
) |
Checks whether a stauts code is equal to another status object.
lhs | The status code to compare. |
rhs | The status object to compare. |
bool tkrzw::operator!= | ( | const Status::Code & | lhs, |
const Status & | rhs | ||
) |
Checks whether a stauts code is not equal to another status object.
lhs | The status code to compare. |
rhs | The status object to compare. |
std::string tkrzw::ToString | ( | const Status & | status | ) |
Converts a status into a string.
status | The status object. |
std::ostream& tkrzw::operator<< | ( | std::ostream & | os, |
const Status & | status | ||
) |
Outputs a status string into an output stream.
os | The output stream. |
status | The status. |
void* tkrzw::xmalloc | ( | size_t | size | ) |
Allocates a region on memory.
size | The size of the region. |
void* tkrzw::xcalloc | ( | size_t | nmemb, |
size_t | size | ||
) |
Allocates a nullified region on memory.
nmemb | The number of elements. |
size | The size of each element. |
void* tkrzw::xrealloc | ( | void * | ptr, |
size_t | size | ||
) |
Re-allocates a region on memory.
ptr | The pointer to the region. |
size | The size of the region. |
void* tkrzw::xreallocappend | ( | void * | ptr, |
size_t | size | ||
) |
Re-allocates a region on memory for appending operations.
ptr | The pointer to the region. |
size | The size of the region. |
void tkrzw::xfree | ( | void * | ptr | ) |
Frees a region on memory.
ptr | The pointer to the region. |
bool tkrzw::CheckSet | ( | SET | set, |
const typename SET::key_type & | elem | ||
) |
Checks whether a set has an element.
set | The set to search. |
elem | The element to search for. |
bool tkrzw::CheckMap | ( | MAP | map, |
const typename MAP::key_type & | key | ||
) |
Checks whether a map has a key.
map | The map to search. |
key | The key to search for. |
MAP::value_type::first_type tkrzw::SearchMap | ( | MAP | map, |
const typename MAP::key_type & | key, | ||
const typename MAP::value_type::second_type & | default_value | ||
) |
Searches a map and get the value of a record.
map | The map to search. |
key | The key to search for. |
default_value | The value to be returned on failure. |
uint64_t tkrzw::HashMurmur | ( | const void * | buf, |
size_t | size, | ||
uint64_t | seed | ||
) |
Gets the hash value by Murmur hashing.
buf | The source buffer. |
size | The size of the source buffer. |
seed | The seed value. |
uint64_t tkrzw::HashMurmur | ( | std::string_view | str, |
uint64_t | seed | ||
) |
Gets the hash value by Murmur hashing.
uint64_t tkrzw::HashFNV | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by FNV hashing.
buf | The source buffer. |
size | The size of the source buffer. |
uint64_t tkrzw::HashFNV | ( | std::string_view | str | ) |
Gets the hash value by FNV hashing.
uint32_t tkrzw::HashCRC32Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 0xFFFFFFFF |
||
) |
Gets the hash value by CRC-32, in a continuous way.
buf | The source buffer. |
size | The size of the source buffer. |
finish | True if the cycle is to be finished. |
seed | A seed value. This should be 0xFFFFFFFF for the frist call of the cycle. |
uint32_t tkrzw::HashCRC32 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by CRC-32.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashCRC32 | ( | const std::string & | str | ) |
Gets the hash value by CRC-32.
uint64_t tkrzw::MakeRandomInt | ( | ) |
Makes a random integer from a hidden seed.
double tkrzw::MakeRandomDouble | ( | ) |
Makes a random real number from a hidden seed.
Status tkrzw::GetErrnoStatus | ( | const char * | call_name, |
int32_t | sys_err_num | ||
) |
Gets a status according to a system error number of a system call.
call_name | The name of the system call. |
sys_err_num | The value of "errno". |
int64_t tkrzw::StrToInt | ( | std::string_view | str, |
int64_t | defval = 0 |
||
) |
Converts a decimal string to an integer.
str | The decimal string. |
defval | The default value to be returned on failure. |
int64_t tkrzw::StrToIntMetric | ( | std::string_view | str, |
int64_t | defval = 0 |
||
) |
Converts a decimal string with a metric prefix to an integer.
str | The decimal string, which can be trailed by a binary metric prefix. "K", "M", "G", "T", "P", and "E" are supported. They are case-insensitive. |
defval | The default value to be returned on failure. |
uint64_t tkrzw::StrToIntOct | ( | std::string_view | str, |
uint64_t | defval = 0 |
||
) |
Converts a octal string to an integer.
str | The octal string. |
defval | The default value to be returned on failure. |
uint64_t tkrzw::StrToIntHex | ( | std::string_view | str, |
uint64_t | defval = 0 |
||
) |
Converts a hexadecimal string to an integer.
str | The hexadecimal string. |
defval | The default value to be returned on failure. |
uint64_t tkrzw::StrToIntBigEndian | ( | std::string_view | str | ) |
Converts a big-endian binary string to an integer.
str | The big endian binary string. |
double tkrzw::StrToDouble | ( | std::string_view | str, |
double | defval = 0.0 |
||
) |
Converts a decimal string to a real number.
str | The decimal string. |
defval | The default value to be returned on failure. |
bool tkrzw::StrToBool | ( | std::string_view | str, |
bool | defval = false |
||
) |
Converts a boolean string to a real number.
str | The decimal string. |
defval | The default value to be returned on failure. |
void tkrzw::VSPrintF | ( | std::string * | dest, |
const char * | format, | ||
va_list | ap | ||
) |
Appends a formatted string at the end of a string.
dest | The destination string. |
format | The printf-like format string. The conversion character ‘%’ can be used with such flag characters as ‘s’, ‘d’, ‘o’, ‘u’, ‘x’, ‘X’, ‘c’, ‘e’, ‘E’, ‘f’, ‘g’, ‘G’, and ‘%’. |
ap | Arguments used according to the format string. |
void tkrzw::SPrintF | ( | std::string * | dest, |
const char * | format, | ||
... | |||
) |
Appends a formatted string at the end of a string.
dest | The destination string. |
format | The printf-like format string. The conversion character ‘%’ can be used with such flag characters as ‘s’, ‘d’, ‘o’, ‘u’, ‘x’, ‘X’, ‘c’, ‘e’, ‘E’, ‘f’, ‘g’, ‘G’, and ‘%’. |
... | Arguments used according to the format string. |
std::string tkrzw::SPrintF | ( | const char * | format, |
... | |||
) |
Generates a formatted string.
format | The printf-like format string. The conversion character ‘%’ can be used with such flag characters as ‘s’, ‘d’, ‘o’, ‘u’, ‘x’, ‘X’, ‘c’, ‘e’, ‘E’, ‘f’, ‘g’, ‘G’, and ‘%’. |
... | Arguments used according to the format string. |
std::string tkrzw::ToString | ( | T | data | ) |
Converts an integer to a decimal string.
data | The integer to convert. |
std::string tkrzw::ToString | ( | double | data | ) |
Converts a real number to a decimal string.
data | The real number to convert. |
std::string tkrzw::ToString | ( | float | data | ) |
Converts a real number to a decimal string.
data | The real number to convert. |
std::string tkrzw::ToString | ( | long double | data | ) |
Converts a real number to a decimal string.
data | The real number to convert. |
std::string tkrzw::ToString | ( | bool | data | ) |
Converts a boolean value to a decimal string.
data | The integer to convert. |
std::string tkrzw::ToString | ( | char | data | ) |
Converts a character into a string.
data | The character. |
std::string tkrzw::ToString | ( | const char * | data | ) |
Converts a C-style string into a string.
data | The C-style string to convert. |
std::string tkrzw::ToString | ( | std::string_view | data | ) |
Converts a string view into a string.
data | The string view. |
std::string tkrzw::ToString | ( | const std::string & | data | ) |
Copies a string.
data | The string. |
std::string tkrzw::IntToStrBigEndian | ( | uint64_t | data, |
size_t | size = sizeof(uint64_t) |
||
) |
Converts an integer into a big-endian binary string.
data | The integer to convert. |
size | The size of the converted string. |
std::string tkrzw::StrJoin | ( | const T & | elems, |
const std::string_view & | delim | ||
) |
Converts each record of a container into strings and join them.
elems | An iterable container. |
delim | A string to delimit elements. |
std::string tkrzw::StrCat | ( | ) |
Returns an empty string.
std::string tkrzw::StrCat | ( | const FIRST & | first, |
const REST &... | rest | ||
) |
Concatenates data of arbitrary parameters into a string.
first | The first parameter. |
rest | The rest parameters. |
std::vector<std::string> tkrzw::StrSplit | ( | std::string_view | str, |
char | delim, | ||
bool | skip_empty = false |
||
) |
Splits a string with a delimiter character.
str | The string. |
delim | The delimiter character. |
skip_empty | If true, fields with empty values are skipped. |
std::vector<std::string> tkrzw::StrSplit | ( | std::string_view | str, |
std::string_view | delim, | ||
bool | skip_empty = false |
||
) |
Splits a string with a delimiter string.
str | The string. |
delim | The delimiter string. If it is empty, each character is separated. |
skip_empty | If true, fields with empty values are skipped. |
std::vector<std::string> tkrzw::StrSplitAny | ( | std::string_view | str, |
std::string_view | delims, | ||
bool | skip_empty = false |
||
) |
Splits a string with delimiter characters.
str | The string to split. |
delims | A string containing a set of the delimiters. |
skip_empty | If true, fields with empty values are skipped. |
std::map<std::string, std::string> tkrzw::StrSplitIntoMap | ( | std::string_view | str, |
std::string_view | delim_records, | ||
std::string_view | delim_kv | ||
) |
Splits a string into a key-value map.
str | The string to split. |
delim_records | The delimiter string between records. |
delim_kv | The delimiter string between the key and the value. |
std::string tkrzw::StrUpperCase | ( | std::string_view | str | ) |
Converts letters of a string into upper case.
str | The string to convert. |
std::string tkrzw::StrLowerCase | ( | std::string_view | str | ) |
Converts letters of a string into lower case.
str | The string to convert. |
bool tkrzw::StrContains | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Checks whether a text contains a pattern.
text | The text to search. |
pattern | The pattern to search for. |
bool tkrzw::StrBeginsWith | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Checks whether a text begins with a pattern.
text | The text to search. |
pattern | The pattern to search for. |
bool tkrzw::StrEndsWith | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Checks whether a text ends with a pattern.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrCaseCompare | ( | std::string_view | a, |
std::string_view | b | ||
) |
Compares two strings ignoring case.
a | A string. |
b | The other string. |
int32_t tkrzw::StrSearch | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern, with string::find.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrSearchDoubleLoop | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern, by naive double loop.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrSearchMemchr | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern, with memchr.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrSearchMemmem | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern, with memmem.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrSearchKMP | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern, by Knuth–Morris–Pratt algorithm.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrSearchBM | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern, by Boyer-Moore algorithm.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrSearchRK | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern, by Rabin-Karp algorithm.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrSearchZ | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern, by Z algorithm.
'
text | The text to search. |
pattern | The pattern to search for. |
std::vector<int32_t> tkrzw::StrSearchWhole | ( | std::string_view | text, |
std::string_view | pattern, | ||
size_t | max_results = 0 |
||
) |
Searches a text for a pattern and get indices of all occurrences, with string::find.
text | The text to search. |
pattern | The pattern to search for. |
max_results | The maximum number of results to store. 0 means unlimited. |
std::vector<int32_t> tkrzw::StrSearchWholeKMP | ( | std::string_view | text, |
std::string_view | pattern, | ||
size_t | max_results = 0 |
||
) |
Searches a text for a pattern and get indices of all occurrences, by KMP algorithm.
text | The text to search. |
pattern | The pattern to search for. |
max_results | The maximum number of results to store. 0 means unlimited. |
std::vector<int32_t> tkrzw::StrSearchWholeBM | ( | std::string_view | text, |
std::string_view | pattern, | ||
size_t | max_results = 0 |
||
) |
Searches a text for a pattern and get indices of all occurrences, by BM algorithm.
text | The text to search. |
pattern | The pattern to search for. |
max_results | The maximum number of results to store. 0 means unlimited. |
std::vector<int32_t> tkrzw::StrSearchWholeRK | ( | std::string_view | text, |
std::string_view | pattern, | ||
size_t | max_results = 0 |
||
) |
Searches a text for a pattern and get indices of all occurrences, by RK algorithm.
text | The text to search. |
pattern | The pattern to search for. |
max_results | The maximum number of results to store. 0 means unlimited. |
std::vector<std::vector<int32_t> > tkrzw::StrSearchBatch | ( | std::string_view | text, |
const std::vector< std::string > & | patterns, | ||
size_t | max_results = 0 |
||
) |
Searches a text for patterns and get indices of all occurrences, by string::find.
text | The text to search. |
patterns | The patterns to search for. |
max_results | The maximum number of results to store for each pattern. 0 means unlimited. |
std::vector<std::vector<int32_t> > tkrzw::StrSearchBatchKMP | ( | std::string_view | text, |
const std::vector< std::string > & | patterns, | ||
size_t | max_results = 0 |
||
) |
Searches a text for patterns and get indices of all occurrences, by KMP algorithm.
text | The text to search. |
patterns | The patterns to search for. |
max_results | The maximum number of results to store for each pattern. 0 means unlimited. |
std::vector<std::vector<int32_t> > tkrzw::StrSearchBatchBM | ( | std::string_view | text, |
const std::vector< std::string > & | patterns, | ||
size_t | max_results = 0 |
||
) |
Searches a text for patterns and get indices of all occurrences, by BM algorithm.
text | The text to search. |
patterns | The patterns to search for. |
max_results | The maximum number of results to store for each pattern. 0 means unlimited. |
std::vector<std::vector<int32_t> > tkrzw::StrSearchBatchRK | ( | std::string_view | text, |
const std::vector< std::string > & | patterns, | ||
size_t | max_results = 0 |
||
) |
Searches a text for patterns and get indices of all occurrences, by RK algorithm.
text | The text to search. |
patterns | The patterns to search for. |
max_results | The maximum number of results to store for each pattern. 0 means unlimited. |
std::string tkrzw::StrStripSpace | ( | std::string_view | str | ) |
Removes space characters at the head or the tail of a string.
str | The string to convert. |
std::string tkrzw::StrStripLine | ( | std::string_view | str | ) |
Removes linefeed characters from the end of a string.
str | The string to convert. |
std::string tkrzw::StrSqueezeAndStripSpace | ( | std::string_view | str | ) |
Squeezes space characters in a string and removes spaces at both ends.
str | The string to convert. |
std::string tkrzw::StrTrimForTSV | ( | std::string_view | str | ) |
Trims a string for TSV by normalizing space and control characters.
str | The string to convert. |
std::string tkrzw::StrEscapeC | ( | std::string_view | str, |
bool | esc_nonasc = false |
||
) |
Escapes C-style meta characters in a string.
str | The string to convert. |
esc_nonasc | If true, non-ASCII characters are excaped. |
std::string tkrzw::StrUnescapeC | ( | std::string_view | str | ) |
Unescapes C-style escape sequences in a string.
str | The string to convert. |
std::string tkrzw::StrEncodeBase64 | ( | std::string_view | str | ) |
Encodes a string into a Base64 string.
str | The string to encode. |
std::string tkrzw::StrDecodeBase64 | ( | std::string_view | str | ) |
Decodes a Base64 string into a string.
str | The Base64 string to decode. |
std::string tkrzw::StrEncodeURL | ( | std::string_view | str | ) |
Encodes a string into a URL part string.
str | The string to encode. |
std::string tkrzw::StrDecodeURL | ( | std::string_view | str | ) |
Decodes a URL part string into a string.
str | The URL part string to decode. |
std::vector<uint32_t> tkrzw::ConvertUTF8ToUCS4 | ( | std::string_view | utf | ) |
Converts a UTF-8 string into a UCS-4 vector.
utf | The UTF-8 string. |
std::string tkrzw::ConvertUCS4ToUTF8 | ( | const std::vector< uint32_t > & | ucs | ) |
Converts a UCS-4 vector into a UTF-8 string.
ucs | The UCS-4 vector. |
std::wstring tkrzw::ConvertUTF8ToWide | ( | std::string_view | utf | ) |
Converts a UTF-8 string into a wide string.
utf | The UTF-8 string. |
std::string tkrzw::ConvertWideToUTF8 | ( | const std::wstring & | wstr | ) |
Converts a wide string into a UTF-8 string.
wstr | The wide string. |
std::string tkrzw::MakeRandomCharacterText | ( | int32_t | length, |
uint8_t | first_char, | ||
uint8_t | last_char | ||
) |
Makes a text composed of characters selected at random.
length | Length of the result text. |
first_char | The first character of the character range. |
last_char | The last character of the character range. |
std::string tkrzw::SerializeStrPair | ( | std::string_view | first, |
std::string_view | second | ||
) |
Serializes a pair of strings into a string.
first | The first string. |
second | The second string. |
The size of the first value and the size of the second value come in the byte delta encoding. The first data and the second data follow them.
void tkrzw::DeserializeStrPair | ( | std::string_view | serialized, |
std::string_view * | first, | ||
std::string_view * | second | ||
) |
Deserializes a serialized string into a pair of strings.
serialized | The serialized string. |
first | The pointer to a string view object to refer to the first string. |
second | The pointer to a string view object to refer to the second string. |
std::string_view tkrzw::GetFirstFromSerializedStrPair | ( | std::string_view | serialized | ) |
Get the first part from a serialized string pair.
serialized | The serialized string. |
std::string tkrzw::SerializeStrVector | ( | const std::vector< std::string > & | values | ) |
Serializes a vector of strings into a string.
values | The string vector. |
The size of a value comes in the byte delta encoding and the data follows. The pairs for all values come consequitively.
std::vector<std::string> tkrzw::DeserializeStrVector | ( | std::string_view | serialized | ) |
Deserializes a serialized string into a string vector.
serialized | The serialized string. |
std::string tkrzw::SerializeStrMap | ( | const std::map< std::string, std::string > & | records | ) |
Serializes a map of strings into a string.
records | The string map. |
The size of a kay comes in the byte delta encoding and the data follows. The size of its value comes in the byte delta encoding and the data follows. The tuples for all records come consequitively.
std::map<std::string, std::string> tkrzw::DeserializeStrMap | ( | std::string_view | serialized | ) |
Deserializes a serialized string into a string map.
serialized | The serialized string. |
double tkrzw::GetWallTime | ( | ) |
Gets the number of seconds since the UNIX epoch.
void tkrzw::Sleep | ( | double | sec | ) |
Sleeps the current thread.
sec | The duration in seconds to sleep for. |
constexpr int8_t tkrzw::INT8MIN = std::numeric_limits<int8_t>::min() |
The minimum value of int8_t.
constexpr int8_t tkrzw::INT8MAX = std::numeric_limits<int8_t>::max() |
The maximum value of int8_t.
constexpr uint8_t tkrzw::UINT8MAX = std::numeric_limits<uint8_t>::max() |
The maximum value of uint8_t.
constexpr int16_t tkrzw::INT16MIN = std::numeric_limits<int16_t>::min() |
The minimum value of int16_t.
constexpr int16_t tkrzw::INT16MAX = std::numeric_limits<int16_t>::max() |
The maximum value of int16_t.
constexpr uint16_t tkrzw::UINT16MAX = std::numeric_limits<uint16_t>::max() |
The maximum value of uint16_t.
constexpr int32_t tkrzw::INT32MIN = std::numeric_limits<int32_t>::min() |
The minimum value of int32_t.
constexpr int32_t tkrzw::INT32MAX = std::numeric_limits<int32_t>::max() |
The maximum value of int32_t.
constexpr uint32_t tkrzw::UINT32MAX = std::numeric_limits<uint32_t>::max() |
The maximum value of uint32_t.
constexpr int64_t tkrzw::INT64MIN = std::numeric_limits<int64_t>::min() |
The minimum value of int64_t.
constexpr int64_t tkrzw::INT64MAX = std::numeric_limits<int64_t>::max() |
The maximum value of int64_t.
constexpr uint64_t tkrzw::UINT64MAX = std::numeric_limits<uint64_t>::max() |
The maximum value of uint64_t.
constexpr size_t tkrzw::SIZEMAX = std::numeric_limits<size_t>::max() |
The maximum value of size_t.
constexpr float tkrzw::FLOATMIN = std::numeric_limits<float>::min() |
The minimum value of float.
constexpr float tkrzw::FLOATMAX = std::numeric_limits<float>::max() |
The maximum value of float.
constexpr double tkrzw::DOUBLEMIN = std::numeric_limits<double>::min() |
The minimum value of double.
constexpr double tkrzw::DOUBLEMAX = std::numeric_limits<double>::max() |
The maximum value of double.
constexpr double tkrzw::DOUBLENAN = std::numeric_limits<double>::quiet_NaN() |
The quiet Not-a-Number value of double.
constexpr double tkrzw::DOUBLEINF = std::numeric_limits<double>::infinity() |
The positive infinity value of double.
constexpr int32_t tkrzw::NUM_BUFFER_SIZE = 32 |
The buffer size for a numeric string expression.
constexpr int64_t tkrzw::MAX_MEMORY_SIZE = (1LL << 40) |
The maximum memory size.
const int32_t tkrzw::PAGE_SIZE |
The size of a memory page on the OS.
const char* const tkrzw::PACKAGE_VERSION |
The string expression of the package version.
const char* const tkrzw::LIBRARY_VERSION |
The string expression of the library version.
const char* const tkrzw::OS_NAME |
The recognized OS name.
const bool tkrzw::IS_BIG_ENDIAN |
True if the byte order is big endian.