Tkrzw
|
Common namespace of Tkrzw. More...
Classes | |
class | Compressor |
Interfrace of data compression and decompression. More... | |
class | DummyCompressor |
Dummy compressor implemetation. More... | |
class | ZLibCompressor |
Compressor implemeted with ZLib. More... | |
class | ZStdCompressor |
Compressor implemeted with ZStd. More... | |
class | LZ4Compressor |
Compressor implemeted with LZ4. More... | |
class | LZMACompressor |
Compressor implemeted with LZMA. More... | |
class | RC4Compressor |
Compressor implemeted with RC4 encryption. More... | |
class | AESCompressor |
Compressor implemeted with AES encryption. More... | |
class | LinkedHashMap |
Doubly-linked hash map. More... | |
class | LRUCache |
LRU cache. More... | |
class | DoubleLRUCache |
Double-layered LRU cache. More... | |
class | AtomicSet |
Thread-safe wrapper of std::set. More... | |
class | DBM |
Interface of database manager. More... | |
class | AsyncDBM |
Asynchronous database manager adapter. More... | |
class | StatusFuture |
Wrapper of std::future containing a status object and extra data. 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 | HashDBM |
File database manager implementation based on hash table. More... | |
class | HashRecord |
Key and value record structure in the file hash database. More... | |
class | OffsetReader |
Reader of a sequence of offsets. More... | |
struct | FreeBlock |
Free block structure. More... | |
class | FreeBlockPool |
Registry of free blocks. More... | |
class | ParamDBM |
Parametric database manager interface. More... | |
class | PolyDBM |
Polymorphic database manager adapter. 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 | RecordSorter |
Sorter for a large amound of records based on merge sort on files. More... | |
class | StdHashDBM |
On-memory database manager implemented with std::unordered_map. More... | |
class | StdTreeDBM |
On-memory database manager implemented with std::map. 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 | TreeRecord |
Key and value record structure in the file tree database. More... | |
struct | TreeRecordOnStack |
Holder of TreeRecord on stack for search. More... | |
struct | TreeRecordComparator |
Comparator for TreeRecord objects. More... | |
struct | TreeLink |
Link to a child node. More... | |
struct | TreeLinkOnStack |
Holder of TreeLink on stack for search. More... | |
struct | TreeLinkComparator |
Comparator for TreeLink objects. More... | |
class | DBMUpdateLoggerStrDeque |
DBM update logger to store logs into a string deque. More... | |
class | DBMUpdateLoggerDBM |
DBM update logger to replicate updates in another DBM. More... | |
class | DBMUpdateLoggerSecondShard |
Update logger adapter for the second shard and later. More... | |
class | DBMUpdateLoggerMQ |
DBM update logger with a message queue. More... | |
class | File |
Interface of file operations. More... | |
class | MemoryMapFile |
Interface for memory mapping file implementations. More... | |
class | MemoryMapParallelFile |
File implementation by memory mapping and locking for parallel operations. More... | |
class | MemoryMapAtomicFile |
File implementation by memory mapping and locking for atomic operations. More... | |
class | PolyFile |
Polymorphic file adapter. More... | |
class | PositionalFile |
Interface for positional access file implementations. More... | |
class | PositionalParallelFile |
File implementation by positional access and locking for parallel operations. More... | |
class | PositionalAtomicFile |
File implementation with positional access and locking for atomic operations. More... | |
class | StdFile |
File implementation with the std::fstream. More... | |
struct | FileStatus |
Status information of a file. More... | |
class | TemporaryDirectory |
Temporary directory whose life duration is bound with the object. More... | |
class | PageCache |
Page cache for buffering I/O operations. More... | |
class | FileReader |
File reader. More... | |
class | FlatRecord |
Flat record structure in the file. More... | |
class | FlatRecordReader |
Reader of flat records. More... | |
class | FileIndex |
File secondary index implementation with TreeDBM. More... | |
class | MemIndex |
On-memory secondary index implementation with BabyDBM. More... | |
class | PolyIndex |
Polymorphic index manager adapter with PolyDBM. 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 | Status |
Status of operations. More... | |
class | StatusException |
Exception to convey the status of operations. More... | |
class | Logger |
Interface for logging operations. More... | |
class | BaseLogger |
Base implementation for logging operations. More... | |
class | StreamLogger |
Stream implementation for logging operations. More... | |
class | MessageQueue |
Message queue on the file stream. More... | |
class | ScopedStringView |
Wrapper of string_view of allocated memory. More... | |
class | SpinMutex |
Spin lock mutex. More... | |
class | SpinSharedMutex |
Spin lock shared mutex. More... | |
class | SpinWPSharedMutex |
Spin lock shared mutex, with write-preferring policy. More... | |
class | SlottedMutex |
Slotted shared mutex. More... | |
class | ScopedSlottedLock |
Scoped lock with a slotted shared mutex. More... | |
class | HashMutex |
Mutex for a hash table. More... | |
class | ScopedHashLock |
Scoped lock with a mutex for a hash table. More... | |
class | ScopedHashLockMulti |
Scoped lock with multiple mutexes for a hash table. More... | |
class | TaskQueue |
Task queue with a thread pool. More... | |
class | WaitCounter |
Wait counter for monitoring other threads. More... | |
class | SignalBroker |
Broker to send a signal to another thread. More... | |
class | KeySignalBroker |
Broker to send a signal associated with a key to another thread. More... | |
class | SlottedKeySignalBroker |
Slotted broker to send a signal associated with a key to another thread. More... | |
class | ScopedCounter |
Scoped counter for auto increment and decrement. 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... | |
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 | SetAccessStrategyOrDie (File *file, int64_t block_size, bool is_direct_io, bool is_sync_io, bool is_padding, bool is_pagecache) |
Sets access strategy of the positional access file. More... | |
void | SetHeadBufferOfFileOrDie (File *file, int64_t size) |
Sets the head buffer of the positional access file. More... | |
void | PrintDBMRecordsInTSV (DBM *dbm) |
Prints all records of a DBM in TSV format. More... | |
std::string | MakeCyclishText (size_t size, int32_t seed) |
Makes a text whose characters appear in a cyclic pattern. More... | |
std::string | MakeNaturalishText (size_t size, int32_t seed) |
Makes a text whose character distribution is sililar to natural Englsh. 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 | SearchDBMLambda (DBM *dbm, std::function< bool(std::string_view)> matcher, std::vector< std::string > *matched, size_t capacity=0) |
Searches a database and get keys which match a lambda function. More... | |
Status | SearchDBMOrder (DBM *dbm, std::string_view pattern, bool upper, bool inclusive, std::vector< std::string > *matched, size_t capacity=0) |
Searches an ordered database and get keys which match a boundary condition. 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) |
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) |
Searches a database and get keys whose edit distance with a UTF-8 pattern is the least. More... | |
Status | SearchDBMEditDistanceBinary (DBM *dbm, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0) |
Searches a database and get keys whose edit distance with a binary pattern is the least. More... | |
Status | SearchDBMModal (DBM *dbm, std::string_view mode, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0) |
Searches a database and get keys which match a pattern, according to a mode expression. More... | |
Status | ExportDBMToFlatRecords (DBM *dbm, File *dest_file) |
Exports all records of a database to a flat record file. More... | |
Status | ImportDBMFromFlatRecords (DBM *dbm, File *src_file) |
Imports records to a database from a flat record file. More... | |
Status | ExportDBMKeysToFlatRecords (DBM *dbm, File *dest_file) |
Exports the keys of all records of a database to a flat record file. More... | |
Status | ExportDBMToTSV (DBM *dbm, File *dest_file, bool escape=false) |
Exports all records of a database to a TSV file. More... | |
Status | ImportDBMFromTSV (DBM *dbm, File *dest_file, bool unescape=false) |
Imports records to a database from a TSV file. More... | |
Status | ExportDBMKeysAsLines (DBM *dbm, File *dest_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 | SearchTextFileLambda (File *file, std::function< bool(std::string_view)> matcher, std::vector< std::string > *matched, size_t capacity=0) |
Searches a text file and get lines which match a lambda function. More... | |
Status | SearchTextFileRegex (File *file, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0) |
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) |
Searches a text file and get lines whose edit distance with a UTF-8 pattern is the least. More... | |
Status | SearchTextFileEditDistanceBinary (File *file, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0) |
Searches a text file and get lines whose edit distance with a binary pattern is the least. More... | |
Status | SearchTextFileModal (File *file, std::string_view mode, std::string_view pattern, std::vector< std::string > *matched, size_t capacity=0) |
Searches a text file and get lines which match a pattern, according to a mode expression. More... | |
uint32_t | MagicChecksum (const char *key_buf, size_t key_size, const char *value_buf, size_t value_size) |
Calculates the checksum of the record data to store in the record magic data. More... | |
std::string_view | CallRecordProcessFull (DBM::RecordProcessor *proc, std::string_view key, std::string_view old_value, std::string_view *new_value_orig, Compressor *compressor, ScopedStringView *comp_data_placeholder) |
Calls the ProcessFull method of a record processor with compression and decompression. More... | |
std::string_view | CallRecordProcessEmpty (DBM::RecordProcessor *proc, std::string_view key, std::string_view *new_value_orig, Compressor *compressor, ScopedStringView *comp_data_placeholder) |
Calls the ProcessEmpty method of a record processor with compression. 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) |
Writes a file with a content. More... | |
Status | WriteFileAtomic (const std::string &path, std::string_view content, const std::string &tmp_path="") |
Writes a file with a content, in an atomic manner by file renaming. More... | |
Status | ReadFile (const std::string &path, std::string *content, int64_t max_size=INT32MAX) |
Reads the content from a file. More... | |
std::string | ReadFileSimple (const std::string &path, std::string_view default_value="", int64_t max_size=INT32MAX) |
Reads the content from a file, in a simple way. More... | |
Status | TruncateFile (const std::string &path, int64_t size) |
Truncates 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 | CopyFileData (const std::string &src_path, const std::string &dest_path) |
Copies the data of 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... | |
Status | SynchronizeFile (const std::string &path) |
Synchronizes a file or a directory. 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 | HashChecksum6Continuous (const void *buf, size_t size, bool finish, uint32_t seed=0) |
Gets the hash value by Checksum-6, in a continuous way. More... | |
uint32_t | HashChecksum6 (const void *buf, size_t size) |
Gets the hash value by Checksum-6. More... | |
uint32_t | HashChecksum6 (std::string_view str) |
Gets the hash value by Checksum-6. More... | |
uint32_t | HashChecksum6Pair (const void *first_buf, size_t first_size, const void *second_buf, size_t second_size, uint32_t seed=0) |
Gets the hash value by Checksum-6. More... | |
uint32_t | HashChecksum8Continuous (const void *buf, size_t size, bool finish, uint32_t seed=0) |
Gets the hash value by checksum-8, in a continuous way. More... | |
uint32_t | HashChecksum8 (const void *buf, size_t size) |
Gets the hash value by checksum-8. More... | |
uint32_t | HashChecksum8 (std::string_view str) |
Gets the hash value by checksum-8. More... | |
uint32_t | HashChecksum8Pair (const void *first_buf, size_t first_size, const void *second_buf, size_t second_size, uint32_t seed=0) |
Gets the hash value by Checksum-8. More... | |
uint32_t | HashAdler6Continuous (const void *buf, size_t size, bool finish, uint32_t seed=1) |
Gets the hash value by Adler-6, in a continuous way. More... | |
uint32_t | HashAdler6 (const void *buf, size_t size) |
Gets the hash value by Adler-6. More... | |
uint32_t | HashAdler6 (std::string_view str) |
Gets the hash value by Adler-6. More... | |
uint32_t | HashAdler8Continuous (const void *buf, size_t size, bool finish, uint32_t seed=1) |
Gets the hash value by adler-8, in a continuous way. More... | |
uint32_t | HashAdler8 (const void *buf, size_t size) |
Gets the hash value by adler-8. More... | |
uint32_t | HashAdler8 (std::string_view str) |
Gets the hash value by adler-8. More... | |
uint32_t | HashAdler16Continuous (const void *buf, size_t size, bool finish, uint32_t seed=1) |
Gets the hash value by Adler-16, in a continuous way. More... | |
uint32_t | HashAdler16 (const void *buf, size_t size) |
Gets the hash value by Adler-16. More... | |
uint32_t | HashAdler16 (std::string_view str) |
Gets the hash value by Adler-16. More... | |
uint32_t | HashAdler32Continuous (const void *buf, size_t size, bool finish, uint32_t seed=1) |
Gets the hash value by Adler-32, in a continuous way. More... | |
uint32_t | HashAdler32 (const void *buf, size_t size) |
Gets the hash value by Adler-32. More... | |
uint32_t | HashAdler32 (std::string_view str) |
Gets the hash value by Adler-32. More... | |
uint32_t | HashCRC4Continuous (const void *buf, size_t size, bool finish, uint32_t seed=0) |
Gets the hash value by CRC-4, in a continuous way. More... | |
uint32_t | HashCRC4 (const void *buf, size_t size) |
Gets the hash value by CRC-4. More... | |
uint32_t | HashCRC4 (std::string_view str) |
Gets the hash value by CRC-4. More... | |
uint32_t | HashCRC8Continuous (const void *buf, size_t size, bool finish, uint32_t seed=0) |
Gets the hash value by CRC-8, in a continuous way. More... | |
uint32_t | HashCRC8 (const void *buf, size_t size) |
Gets the hash value by CRC-8. More... | |
uint32_t | HashCRC8 (std::string_view str) |
Gets the hash value by CRC-8. More... | |
uint32_t | HashCRC16Continuous (const void *buf, size_t size, bool finish, uint32_t seed=0) |
Gets the hash value by CRC-16, in a continuous way. More... | |
uint32_t | HashCRC16 (const void *buf, size_t size) |
Gets the hash value by CRC-16. More... | |
uint32_t | HashCRC16 (std::string_view str) |
Gets the hash value by CRC-16. 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 (std::string_view str) |
Gets the hash value by CRC-32. 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 decimal integer numeric expressions. More... | |
int32_t | HexadecimalKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the order of hexadecimal integer numeric expressions. More... | |
int32_t | RealNumberKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the order of decimal real number expressions. More... | |
int32_t | SignedBigEndianKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the order of big-endian binaries of signed integer numbers. More... | |
int32_t | FloatBigEndianKeyComparator (std::string_view a, std::string_view b) |
Key comparator in the order of big-endian binaries of floating-point numbers. 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... | |
int32_t | PairSignedBigEndianKeyComparator (std::string_view a, std::string_view b) |
Key comparator for serialized pair strings in the big-endian binary signed integer order. More... | |
int32_t | PairFloatBigEndianKeyComparator (std::string_view a, std::string_view b) |
Key comparator for serialized pair strings in the big-endian binary floating-point number order. 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... | |
void * | xmallocaligned (size_t alignment, size_t size) |
Allocates an aligned region on memory. More... | |
void | xfreealigned (void *ptr) |
Frees an aligned region on memory. More... | |
void * | xmemcpybigendian (void *dest, const void *src, size_t width) |
Copies memory area by normalizing the byte order into the big endian. 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::second_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... | |
int64_t | GetProcessID () |
Gets the current processs ID. More... | |
std::map< std::string, std::string > | GetSystemInfo () |
Gets system information of the environment. More... | |
int64_t | GetMemoryCapacity () |
Gets the memory capacity of the platform. More... | |
int64_t | GetMemoryUsage () |
Gets the current memory usage of the process. More... | |
bool | operator== (const Status::Code &lhs, const Status &rhs) |
Checks whether a status code is equal to another status object. More... | |
bool | operator!= (const Status::Code &lhs, const Status &rhs) |
Checks whether a status 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... | |
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... | |
double | StrToDouble (std::string_view str, double defval=0.0) |
Converts a decimal string to a real number. More... | |
uint64_t | StrToIntBigEndian (std::string_view str) |
Converts a big-endian binary string to an integer. More... | |
long double | StrToFloatBigEndian (std::string_view str) |
Converts a big-endian binary string to a real number. More... | |
uint64_t | StrToIntDelta (std::string_view str, bool zigzag) |
Converts a byte-delta-encoded string into an integer. More... | |
bool | StrToBool (std::string_view str, bool defval=false) |
Converts a boolean string to a boolean value. More... | |
int64_t | StrToIntOrBool (std::string_view str, int64_t defval=0) |
Converts a decimal or boolean string to an integer or boolean value. 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... | |
std::string | FloatToStrBigEndian (long double data, size_t size=sizeof(double)) |
Converts a floating-point number into a big-endian binary string. More... | |
std::string | IntToStrDelta (uint64_t data, bool zigzag) |
Converts an integer into a string in byte delta encoding. More... | |
template<typename T > | |
std::string | StrJoin (const T &elems, 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... | |
void | StrUpperCase (std::string *str) |
Converts letters of a string into upper case in-place. More... | |
std::string | StrLowerCase (std::string_view str) |
Converts letters of a string into lower case. More... | |
void | StrLowerCase (std::string *str) |
Converts letters of a string into lower case in-place. More... | |
std::string | StrReplace (std::string_view str, std::string_view before, std::string_view after) |
Converts a string by replacing substrings to diffent substrings. More... | |
void | StrReplaceCharacters (std::string *str, std::string_view before, std::string_view after) |
Modifies a string by replacing characters to diffent characters in-place. More... | |
bool | StrContains (std::string_view text, std::string_view pattern) |
Checks whether a text contains a pattern. More... | |
bool | StrCaseContains (std::string_view text, std::string_view pattern) |
Checks whether a text contains a pattern in a case-insensitive manner. More... | |
bool | StrWordContains (std::string_view text, std::string_view pattern) |
Checks whether a text contains a word surrounded by non-alphanumeric word boundaries. More... | |
bool | StrCaseWordContains (std::string_view text, std::string_view pattern) |
Checks whether a text contains a word in a case-sensitive manner. More... | |
bool | StrContainsBatch (std::string_view text, const std::vector< std::string > &patterns) |
Checks a text contains at least one of patterns. More... | |
bool | StrCaseContainsBatch (std::string_view text, const std::vector< std::string > &patterns) |
Checks a text contains at least one of patterns in a case-sensitive manner. More... | |
bool | StrWordContainsBatch (std::string_view text, const std::vector< std::string > &patterns) |
Checks a text contains at least one of words surrounded by non-alphanumeric word boundaries. More... | |
bool | StrCaseWordContainsBatch (std::string_view text, const std::vector< std::string > &patterns) |
Checks a text contains at least one of words in a case-sensitive manner. More... | |
bool | StrCaseWordContainsBatchLower (std::string_view text, const std::vector< std::string > &patterns) |
Checks a text contains at least one of lowercase words in a case-sensitive manner. 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... | |
int32_t | StrCaseSearch (std::string_view text, std::string_view pattern) |
Searches a text for a pattern in a case-insensitive manner. More... | |
int32_t | StrWordSearch (std::string_view text, std::string_view pattern) |
Searches a text for a word surrounded by non-alphanumeric word boundaries. More... | |
int32_t | StrCaseWordSearch (std::string_view text, std::string_view pattern) |
Searches a text for a word surrounded in a case-insensitive manner. 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... | |
void | StrStripLine (std::string *str) |
Remove linefeed characters from the end of a string in-place. 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, bool keep_tab=false) |
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... | |
int32_t | StrSearchRegex (std::string_view text, std::string_view pattern) |
Searches a string for a pattern matching a regular expression. More... | |
std::string | StrReplaceRegex (std::string_view text, std::string_view pattern, std::string_view replace) |
Replaces substrings matching a pattern of regular expression. 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 | 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::vector< std::string > | MakeStrVectorFromViews (const std::vector< std::string_view > &views) |
Makes a string vector from a string view vector. More... | |
std::vector< std::string_view > | MakeStrViewVectorFromValues (const std::vector< std::string > &values) |
Makes a string view vector from 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... | |
std::map< std::string, std::string > | MakeStrMapFromViews (const std::map< std::string_view, std::string_view > &views) |
Makes a string map from a string view map. More... | |
std::map< std::string_view, std::string_view > | MakeStrViewMapFromRecords (const std::map< std::string, std::string > &records) |
Makes a string view map from a string map. More... | |
template<typename T > | |
std::string | SerializeBasicValue (T value) |
Serializes a value of a basic type into a string. More... | |
template<typename T > | |
T | DeserializeBasicValue (std::string_view serialized) |
Deserializes a string into a value of a basic type. More... | |
template<typename T > | |
std::string | SerializeBasicVector (const std::vector< T > &values) |
Serializes a vector of a basic type into a string. More... | |
template<typename T > | |
std::vector< T > | DeserializeBasicVector (std::string_view serialized) |
Deserializes a string into a vector of a basic type. More... | |
template<typename T > | |
std::string | SerializeIntVectorDelta (const std::vector< T > &values, bool zigzag) |
Serializes a vector of an integer type into a string in byte delta encoding. More... | |
template<typename T > | |
std::vector< T > | DeserializeIntVectorDelta (std::string_view serialized, bool zigzag) |
Deserializes a byte-delta-encoded string into a vector of an integer type. More... | |
void | SleepThread (double sec) |
Sleeps the current thread. More... | |
double | GetWallTime () |
Gets the number of seconds since the UNIX epoch. More... | |
void | GetLocalCalendar (int64_t wtime, struct std::tm *cal) |
Gets the local calendar of a time. More... | |
void | GetUniversalCalendar (int64_t wtime, struct std::tm *cal) |
Gets the universal calendar of a time. More... | |
int64_t | MakeUniversalTime (struct std::tm &cal) |
Makes the UNIX time from a universal calendar. More... | |
int32_t | GetLocalTimeDifference (bool use_cache=false) |
Gets the time difference of the local time zone. More... | |
int32_t | GetDayOfWeek (int32_t year, int32_t mon, int32_t day) |
Gets the day of week of a date. More... | |
size_t | FormatDateSimple (char *result, int64_t wtime=INT64MIN, int32_t td=INT32MIN) |
Formats a date as a simple string in "YYYY/MM/DD hh:mm:ss" format. More... | |
size_t | FormatDateSimpleWithFrac (char *result, double wtime=-1, int32_t td=INT32MIN, int32_t frac_cols=6) |
Formats a date as a simple string in "YYYY/MM/DD hh:mm:ss" format. More... | |
size_t | FormatDateW3CDTF (char *result, int64_t wtime=INT64MIN, int32_t td=INT32MIN) |
Formats a date as a string in W3CDTF. More... | |
size_t | FormatDateW3CDTFWithFrac (char *result, double wtime=-1, int32_t td=INT32MIN, int32_t frac_cols=6) |
Formats a date as a string in W3CDTF. More... | |
size_t | FormatDateRFC1123 (char *result, int64_t wtime=INT64MIN, int32_t td=INT32MIN) |
Formats a date as a string in RFC 1123 format. More... | |
double | ParseDateStr (std::string_view str) |
Parses a date string to get the time value since the UNIX epoch. More... | |
double | ParseDateStrYYYYMMDD (std::string_view str, int32_t td=INT32MIN) |
Parses a date string in "YYYYMMDD" to get the time value since the UNIX epoch. More... | |
std::string | MakeRelativeTimeExpr (double diff) |
Makes a human-readable relative time expression of a time difference. More... | |
Variables | |
const char | DIR_SEP_CHR |
Directory separator character. More... | |
const char *const | DIR_SEP_STR |
Directory separator string. More... | |
const char | EXT_SEP_CHR |
Extension separator character. More... | |
const char *const | EXT_SEP_STR |
Extension separator string. More... | |
const char *const | CURRENT_DIR_NAME |
Current directory name. More... | |
const char *const | PARENT_DIR_NAME |
Parent directory name. More... | |
constexpr int8_t | INT8MIN = std::numeric_limits<int8_t>::min() |
Disable macros to avoid possible name confliction. 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_POSIX |
True if the OS is conforming to POSIX. 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. |
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::SetAccessStrategyOrDie | ( | File * | file, |
int64_t | block_size, | ||
bool | is_direct_io, | ||
bool | is_sync_io, | ||
bool | is_padding, | ||
bool | is_pagecache | ||
) |
Sets access strategy of the positional access file.
file | The file object. |
block_size | The block size to which all records should be aligned. |
is_direct_io | If true, the direct I/O access option is set. |
is_sync_io | If true, the synchronous I/O access option is set. |
is_padding | If true, the padding access option is set. |
is_pagecache | If true, the mini page cache option is set. |
void tkrzw::SetHeadBufferOfFileOrDie | ( | File * | file, |
int64_t | size | ||
) |
Sets the head buffer of the positional access file.
file | The file object. |
size | The size of the head buffer. |
void tkrzw::PrintDBMRecordsInTSV | ( | DBM * | dbm | ) |
std::string tkrzw::MakeCyclishText | ( | size_t | size, |
int32_t | seed | ||
) |
Makes a text whose characters appear in a cyclic pattern.
size | The size of the output text. |
seed | The random seed. |
std::string tkrzw::MakeNaturalishText | ( | size_t | size, |
int32_t | seed | ||
) |
Makes a text whose character distribution is sililar to natural Englsh.
size | The size of the output text. |
seed | The random seed. |
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::SearchDBMLambda | ( | DBM * | dbm, |
std::function< bool(std::string_view)> | matcher, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a database and get keys which match a lambda function.
dbm | The DBM object of the database. |
matcher | A matching function which takes a candidate. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
This scans the whole database so it can take long time.
Status tkrzw::SearchDBMOrder | ( | DBM * | dbm, |
std::string_view | pattern, | ||
bool | upper, | ||
bool | inclusive, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches an ordered database and get keys which match a boundary condition.
dbm | The DBM object of the database. |
pattern | The boundary pattern of the origin. |
upper | If true, keys whose positions are upper than the boundary pattern are picked up. If false, keys whose positions are lower than the boundary pattern are picked up. |
inclusive | If true, keys whose position are the same as the boundary pattern are included. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
Even if there's no matching record, the operation doesn't fail. This method is suppoerted only for ordered databases.
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 |
||
) |
Searches a database and get keys which match a regular expression.
dbm | The DBM object of the database. |
pattern | The regular expression pattern to search for. Leading "(?i)" makes the pattern case-insensitive. Other options "a" (AWK regex), "b" (basic POSIX regex), "e" (extended POSIX regex), and "l" (egrep) are available in addition to "i". The default regex format is ECMAScript. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
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 |
||
) |
Searches a database and get keys whose edit distance with a UTF-8 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. |
This scans the whole database so it can take long time.
Status tkrzw::SearchDBMEditDistanceBinary | ( | DBM * | dbm, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a database and get keys whose edit distance with a binary 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. |
This scans the whole database so it can take long time.
Status tkrzw::SearchDBMModal | ( | DBM * | dbm, |
std::string_view | mode, | ||
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a database and get keys which match a pattern, according to a mode expression.
dbm | The DBM object of the database. |
mode | The search mode. "contain" extracts keys containing the pattern. "begin" extracts keys beginning with the pattern. "end" extracts keys ending with the pattern. "regex" extracts keys partially matches the pattern of a regular expression. "edit" extracts keys whose edit distance to the UTF-8 pattern is the least. "editbin" extracts keys whose edit distance to the binary pattern is the least. "containcase", "containword", and "containcaseword" extract keys considering case and word boundary. "contain*", "containcase*", "containword*", and "containcaseword*" take a line-feed-separatable pattern and do batch operations for each element. Ordered databases support "upper" and "lower" which extract keys whose positions are upper/lower than the pattern. "upperinc" and "lowerinc" are their inclusive versions. |
pattern | The pattern for matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
Exports all records of a database to a flat record file.
dbm | The DBM object of the database. |
dest_file | The file object to write records in. |
A flat record file contains a sequence of binary records without any high level structure so it is useful as a intermediate file for data migration.
Imports records to a database from a flat record file.
dbm | The DBM object of the database. |
src_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. |
dest_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. |
dest_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. |
dest_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. |
dest_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::SearchTextFileLambda | ( | File * | file, |
std::function< bool(std::string_view)> | matcher, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a text file and get lines which match a lambda function.
file | The file to search. |
matcher | A matching function which takes a candidate. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
Status tkrzw::SearchTextFileRegex | ( | File * | file, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a text file and get lines which match a regular expression.
file | The file to search. |
pattern | The regular expression pattern to search for. Leading "(?i)" makes the pattern case-insensitive. Other options "a" (AWK regex), "b" (basic POSIX regex), "e" (extended POSIX regex), and "l" (egrep) are available in addition to "i". The default regex format is ECMAScript. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
Status tkrzw::SearchTextFileEditDistance | ( | File * | file, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a text file and get lines whose edit distance with a UTF-8 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. |
Status tkrzw::SearchTextFileEditDistanceBinary | ( | File * | file, |
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a text file and get lines whose edit distance with a binary 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. |
Status tkrzw::SearchTextFileModal | ( | File * | file, |
std::string_view | mode, | ||
std::string_view | pattern, | ||
std::vector< std::string > * | matched, | ||
size_t | capacity = 0 |
||
) |
Searches a text file and get lines which match a pattern, according to a mode expression.
file | The file to search. |
mode | The search mode. "contain" extracts keys containing the pattern. "begin" extracts keys beginning with the pattern. "end" extracts keys ending with the pattern. "regex" extracts keys partially matches the pattern of a regular expression. "edit" extracts keys whose edit distance to the UTF-8 pattern is the least. "editbin" extracts keys whose edit distance to the binary pattern is the least. "containcase", "containword", and "containcaseword" extract keys considering case and word boundary. "contain*", "containcase*", "containword*", and "containcaseword*" take a line-separatable pattern and do batch operations for each elements. |
pattern | The pattern for matching. |
matched | A vector to contain the result. |
capacity | The maximum records to obtain. 0 means unlimited. |
uint32_t tkrzw::MagicChecksum | ( | const char * | key_buf, |
size_t | key_size, | ||
const char * | value_buf, | ||
size_t | value_size | ||
) |
Calculates the checksum of the record data to store in the record magic data.
key_buf | The key buffer. |
key_size | The key size. |
value_buf | The value buffer. |
value_size | The value size. |
std::string_view tkrzw::CallRecordProcessFull | ( | DBM::RecordProcessor * | proc, |
std::string_view | key, | ||
std::string_view | old_value, | ||
std::string_view * | new_value_orig, | ||
Compressor * | compressor, | ||
ScopedStringView * | comp_data_placeholder | ||
) |
Calls the ProcessFull method of a record processor with compression and decompression.
proc | The record processor, which takes a decompressed value. |
key | The key of a record. |
old_value | The old value of the record. |
new_value_orig | The pointer to store the original new value before compression. |
compressor | The compressor object for compression and decompression. nullptr is OK. |
comp_data_placeholder | The praceholder to manage the compression data. |
std::string_view tkrzw::CallRecordProcessEmpty | ( | DBM::RecordProcessor * | proc, |
std::string_view | key, | ||
std::string_view * | new_value_orig, | ||
Compressor * | compressor, | ||
ScopedStringView * | comp_data_placeholder | ||
) |
Calls the ProcessEmpty method of a record processor with compression.
proc | The record processor. |
key | The key of a record. |
new_value_orig | The pointer to store the original new value before compression. |
compressor | The compressor object for compression and decompression. nullptr is OK. |
comp_data_placeholder | The praceholder to manage the compression data. |
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 | ||
) |
Writes a file with a content.
path | The path of the file to write. |
content | The content. |
Status tkrzw::WriteFileAtomic | ( | const std::string & | path, |
std::string_view | content, | ||
const std::string & | tmp_path = "" |
||
) |
Writes a file with a content, in an atomic manner by file renaming.
path | The path of the file to write. |
content | The content. |
tmp_path | The path of the temporary file which is renamed to the above path. If it is empty, a string made of the original path and the extension ".tmp" is used. |
Status tkrzw::ReadFile | ( | const std::string & | path, |
std::string * | content, | ||
int64_t | max_size = INT32MAX |
||
) |
Reads the content from a file.
path | The path of the file to make. |
content | The pointer to a string object to contain the content. |
max_size | The maximum size in bytes to read. |
std::string tkrzw::ReadFileSimple | ( | const std::string & | path, |
std::string_view | default_value = "" , |
||
int64_t | max_size = INT32MAX |
||
) |
Reads the content from a file, in a simple way.
path | The path of the file to make. |
default_value | The value to be returned on failure. |
max_size | The maximum size in bytes to read. |
Status tkrzw::TruncateFile | ( | const std::string & | path, |
int64_t | size | ||
) |
Truncates a file.
path | The path of the file to truncate. |
size | The new size of the file. |
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. |
If there is a file at the destination path, the file is overwritten. This function can rename directories too.
Status tkrzw::CopyFileData | ( | const std::string & | src_path, |
const std::string & | dest_path | ||
) |
Copies the data of a file.
src_path | The source path of the file. |
dest_path | The destination path of the file. |
Copying is done in the fastest way available on the platform.
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. |
Status tkrzw::SynchronizeFile | ( | const std::string & | path | ) |
Synchronizes a file or a directory.
path | The path of the file or the directory. |
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::HashChecksum6Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 0 |
||
) |
Gets the hash value by Checksum-6, 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 0 for the frist call of the cycle. |
uint32_t tkrzw::HashChecksum6 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by Checksum-6.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashChecksum6 | ( | std::string_view | str | ) |
Gets the hash value by Checksum-6.
uint32_t tkrzw::HashChecksum6Pair | ( | const void * | first_buf, |
size_t | first_size, | ||
const void * | second_buf, | ||
size_t | second_size, | ||
uint32_t | seed = 0 |
||
) |
Gets the hash value by Checksum-6.
uint32_t tkrzw::HashChecksum8Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 0 |
||
) |
Gets the hash value by checksum-8, 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 0 for the frist call of the cycle. |
uint32_t tkrzw::HashChecksum8 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by checksum-8.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashChecksum8 | ( | std::string_view | str | ) |
Gets the hash value by checksum-8.
uint32_t tkrzw::HashChecksum8Pair | ( | const void * | first_buf, |
size_t | first_size, | ||
const void * | second_buf, | ||
size_t | second_size, | ||
uint32_t | seed = 0 |
||
) |
Gets the hash value by Checksum-8.
uint32_t tkrzw::HashAdler6Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 1 |
||
) |
Gets the hash value by Adler-6, 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 1 for the frist call of the cycle. |
uint32_t tkrzw::HashAdler6 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by Adler-6.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashAdler6 | ( | std::string_view | str | ) |
Gets the hash value by Adler-6.
uint32_t tkrzw::HashAdler8Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 1 |
||
) |
Gets the hash value by adler-8, 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 1 for the frist call of the cycle. |
uint32_t tkrzw::HashAdler8 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by adler-8.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashAdler8 | ( | std::string_view | str | ) |
Gets the hash value by adler-8.
uint32_t tkrzw::HashAdler16Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 1 |
||
) |
Gets the hash value by Adler-16, 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 1 for the frist call of the cycle. |
uint32_t tkrzw::HashAdler16 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by Adler-16.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashAdler16 | ( | std::string_view | str | ) |
Gets the hash value by Adler-16.
uint32_t tkrzw::HashAdler32Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 1 |
||
) |
Gets the hash value by Adler-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 1 for the frist call of the cycle. |
uint32_t tkrzw::HashAdler32 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by Adler-32.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashAdler32 | ( | std::string_view | str | ) |
Gets the hash value by Adler-32.
uint32_t tkrzw::HashCRC4Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 0 |
||
) |
Gets the hash value by CRC-4, 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 0 for the frist call of the cycle. |
uint32_t tkrzw::HashCRC4 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by CRC-4.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashCRC4 | ( | std::string_view | str | ) |
Gets the hash value by CRC-4.
uint32_t tkrzw::HashCRC8Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 0 |
||
) |
Gets the hash value by CRC-8, 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 0 for the frist call of the cycle. |
uint32_t tkrzw::HashCRC8 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by CRC-8.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashCRC8 | ( | std::string_view | str | ) |
Gets the hash value by CRC-8.
uint32_t tkrzw::HashCRC16Continuous | ( | const void * | buf, |
size_t | size, | ||
bool | finish, | ||
uint32_t | seed = 0 |
||
) |
Gets the hash value by CRC-16, 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 0 for the frist call of the cycle. |
uint32_t tkrzw::HashCRC16 | ( | const void * | buf, |
size_t | size | ||
) |
Gets the hash value by CRC-16.
buf | The source buffer. |
size | The size of the source buffer. |
uint32_t tkrzw::HashCRC16 | ( | std::string_view | str | ) |
Gets the hash value by CRC-16.
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 | ( | std::string_view | str | ) |
Gets the hash value by CRC-32.
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 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 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 decimal real number expressions.
a | One key. |
b | The other key. |
int32_t tkrzw::SignedBigEndianKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator in the order of big-endian binaries of signed integer numbers.
a | One key. |
b | The other key. |
int32_t tkrzw::FloatBigEndianKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator in the order of big-endian binaries of floating-point numbers.
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. |
int32_t tkrzw::PairSignedBigEndianKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator for serialized pair strings in the big-endian binary signed integer order.
a | One key. |
b | The other key. |
int32_t tkrzw::PairFloatBigEndianKeyComparator | ( | std::string_view | a, |
std::string_view | b | ||
) |
Key comparator for serialized pair strings in the big-endian binary floating-point number order.
a | One key. |
b | The other key. |
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. |
void* tkrzw::xmallocaligned | ( | size_t | alignment, |
size_t | size | ||
) |
Allocates an aligned region on memory.
alignment | The alignment of the address. It must be a power of two and more than sizeof(void*). |
size | The size of the region. It is ceiled implicitly to a multiple of the alignment. |
void tkrzw::xfreealigned | ( | void * | ptr | ) |
Frees an aligned region on memory.
ptr | The pointer to the region. |
void* tkrzw::xmemcpybigendian | ( | void * | dest, |
const void * | src, | ||
size_t | width | ||
) |
Copies memory area by normalizing the byte order into the big endian.
dest | The memory area of the destination. It must not be overlap with the source area. |
src | The memory area of the source data. |
width | The width of each memory area. |
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::second_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. |
int64_t tkrzw::GetProcessID | ( | ) |
Gets the current processs ID.
std::map<std::string, std::string> tkrzw::GetSystemInfo | ( | ) |
Gets system information of the environment.
int64_t tkrzw::GetMemoryCapacity | ( | ) |
Gets the memory capacity of the platform.
int64_t tkrzw::GetMemoryUsage | ( | ) |
Gets the current memory usage of the process.
bool tkrzw::operator== | ( | const Status::Code & | lhs, |
const Status & | rhs | ||
) |
Checks whether a status 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 status 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. |
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. |
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. |
uint64_t tkrzw::StrToIntBigEndian | ( | std::string_view | str | ) |
Converts a big-endian binary string to an integer.
str | The big endian binary string of up to 8-byte. |
long double tkrzw::StrToFloatBigEndian | ( | std::string_view | str | ) |
Converts a big-endian binary string to a real number.
str | The big endian binary string of 4-byte (float), 8-byte (double), or larger (long double). |
uint64_t tkrzw::StrToIntDelta | ( | std::string_view | str, |
bool | zigzag | ||
) |
Converts a byte-delta-encoded string into an integer.
str | The big endian binary string of up to 8-byte. |
zigzag | If true, negative values are also supported by applying zigzag encoding. |
bool tkrzw::StrToBool | ( | std::string_view | str, |
bool | defval = false |
||
) |
Converts a boolean string to a boolean value.
str | The decimal string. |
defval | The default value to be returned on failure. |
int64_t tkrzw::StrToIntOrBool | ( | std::string_view | str, |
int64_t | defval = 0 |
||
) |
Converts a decimal or boolean string to an integer or boolean value.
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::FloatToStrBigEndian | ( | long double | data, |
size_t | size = sizeof(double) |
||
) |
Converts a floating-point number into a big-endian binary string.
data | The floating-point number to convert. |
size | The size of the converted string. |
std::string tkrzw::IntToStrDelta | ( | uint64_t | data, |
bool | zigzag | ||
) |
Converts an integer into a string in byte delta encoding.
data | The integer to convert. |
zigzag | If true, negative values are also supported by applying zigzag encoding. |
std::string tkrzw::StrJoin | ( | const T & | elems, |
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. |
void tkrzw::StrUpperCase | ( | std::string * | str | ) |
Converts letters of a string into upper case in-place.
str | The pointer to the string to modify. |
std::string tkrzw::StrLowerCase | ( | std::string_view | str | ) |
Converts letters of a string into lower case.
str | The string to convert. |
void tkrzw::StrLowerCase | ( | std::string * | str | ) |
Converts letters of a string into lower case in-place.
str | The pointer to the string to modify. |
std::string tkrzw::StrReplace | ( | std::string_view | str, |
std::string_view | before, | ||
std::string_view | after | ||
) |
Converts a string by replacing substrings to diffent substrings.
str | The string to convert. |
before | The substring before replacement. |
after | The substring after replacement. |
void tkrzw::StrReplaceCharacters | ( | std::string * | str, |
std::string_view | before, | ||
std::string_view | after | ||
) |
Modifies a string by replacing characters to diffent characters in-place.
str | The pointer to the string to modify. |
before | The characters to remove. |
after | The characters to insert. The character at the same index as the index of the before character is used. If there's no counterpart, no character is inserted. |
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::StrCaseContains | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Checks whether a text contains a pattern in a case-insensitive manner.
text | The text to search. |
pattern | The pattern to search for. |
bool tkrzw::StrWordContains | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Checks whether a text contains a word surrounded by non-alphanumeric word boundaries.
text | The text to search. |
pattern | The pattern to search for. |
bool tkrzw::StrCaseWordContains | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Checks whether a text contains a word in a case-sensitive manner.
text | The text to search. |
pattern | The pattern to search for. |
bool tkrzw::StrContainsBatch | ( | std::string_view | text, |
const std::vector< std::string > & | patterns | ||
) |
Checks a text contains at least one of patterns.
text | The text to search. |
patterns | The patterns to search for. |
bool tkrzw::StrCaseContainsBatch | ( | std::string_view | text, |
const std::vector< std::string > & | patterns | ||
) |
Checks a text contains at least one of patterns in a case-sensitive manner.
text | The text to search. |
patterns | The patterns to search for. |
bool tkrzw::StrWordContainsBatch | ( | std::string_view | text, |
const std::vector< std::string > & | patterns | ||
) |
Checks a text contains at least one of words surrounded by non-alphanumeric word boundaries.
text | The text to search. |
patterns | The patterns to search for. |
bool tkrzw::StrCaseWordContainsBatch | ( | std::string_view | text, |
const std::vector< std::string > & | patterns | ||
) |
Checks a text contains at least one of words in a case-sensitive manner.
text | The text to search. |
patterns | The patterns to search for. |
bool tkrzw::StrCaseWordContainsBatchLower | ( | std::string_view | text, |
const std::vector< std::string > & | patterns | ||
) |
Checks a text contains at least one of lowercase words in a case-sensitive manner.
text | The text to search. |
patterns | The patterns to search for. Each must be lowercased. |
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. |
int32_t tkrzw::StrCaseSearch | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a pattern in a case-insensitive manner.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrWordSearch | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a word surrounded by non-alphanumeric word boundaries.
text | The text to search. |
pattern | The pattern to search for. |
int32_t tkrzw::StrCaseWordSearch | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a text for a word surrounded in a case-insensitive manner.
text | The text to search. |
pattern | The pattern to search for. |
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. |
void tkrzw::StrStripLine | ( | std::string * | str | ) |
Remove linefeed characters from the end of a string in-place.
str | The pointer to the string to modify. |
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, |
bool | keep_tab = false |
||
) |
Trims a string for TSV by normalizing space and control characters.
str | The string to convert. |
keep_tab | If true, tab is kept and not escaped. |
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. |
int32_t tkrzw::StrSearchRegex | ( | std::string_view | text, |
std::string_view | pattern | ||
) |
Searches a string for a pattern matching a regular expression.
text | The text to search. |
pattern | The regular expression pattern to search for. Leading "(?i)" makes the pattern case-insensitive. Other options "a" (AWK regex), "b" (basic POSIX regex), "e" (extended POSIX regex), and "l" (egrep) are available in addition to "i". The default regex format is ECMAScript. |
std::string tkrzw::StrReplaceRegex | ( | std::string_view | text, |
std::string_view | pattern, | ||
std::string_view | replace | ||
) |
Replaces substrings matching a pattern of regular expression.
text | The text to process. |
pattern | The regular expression pattern to search for. Leading "(?i)" makes the pattern case-insensitive. Other options "a" (AWK regex), "b" (basic POSIX regex), "e" (extended POSIX regex), and "l" (egrep) are available in addition to "i". The default regex format is ECMAScript. |
replace | The replacing expression. "$&" means the entire matched pattern. "$1", "$2", and etc represent n-th bracketed patterns. |
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::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::vector<std::string> tkrzw::MakeStrVectorFromViews | ( | const std::vector< std::string_view > & | views | ) |
Makes a string vector from a string view vector.
views | The string view vector. |
std::vector<std::string_view> tkrzw::MakeStrViewVectorFromValues | ( | const std::vector< std::string > & | values | ) |
Makes a string view vector from a string vector.
values | The string vector. |
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. |
std::map<std::string, std::string> tkrzw::MakeStrMapFromViews | ( | const std::map< std::string_view, std::string_view > & | views | ) |
Makes a string map from a string view map.
views | The string view map. |
std::map<std::string_view, std::string_view> tkrzw::MakeStrViewMapFromRecords | ( | const std::map< std::string, std::string > & | records | ) |
Makes a string view map from a string map.
records | The string map. |
std::string tkrzw::SerializeBasicValue | ( | T | value | ) |
Serializes a value of a basic type into a string.
value | a value of a serializable basic type, like int32 and double. |
The byte order is normalized to the big-endian. Although serializing a value of any trivially-copyable struct is also possible, it is not assured that the data is deserialized properly on another system.
T tkrzw::DeserializeBasicValue | ( | std::string_view | serialized | ) |
Deserializes a string into a value of a basic type.
serialized | The serialized string. |
If the size of the serialized string is not aligned to the size of the data type, zero-initialized value is returned.
std::string tkrzw::SerializeBasicVector | ( | const std::vector< T > & | values | ) |
Serializes a vector of a basic type into a string.
values | a vector of a serializable basic type, like int32 and double. |
The byte order is normalized to the big-endian. Although serializing a value of any trivially-copyable struct is also possible, it is not assured that the data is deserialized properly on another system.
std::vector<T> tkrzw::DeserializeBasicVector | ( | std::string_view | serialized | ) |
Deserializes a string into a vector of a basic type.
serialized | The serialized string. |
If the size of the serialized string is not aligned to the size of the data type, the last element is omitted.
std::string tkrzw::SerializeIntVectorDelta | ( | const std::vector< T > & | values, |
bool | zigzag | ||
) |
Serializes a vector of an integer type into a string in byte delta encoding.
values | a vector of an integer type, like uint16 and int64. |
zigzag | If true, negative values are also supported by applying zigzag encoding. |
std::vector<T> tkrzw::DeserializeIntVectorDelta | ( | std::string_view | serialized, |
bool | zigzag | ||
) |
Deserializes a byte-delta-encoded string into a vector of an integer type.
serialized | The serialized string in byte delta encoding. |
zigzag | If true, negative values are also supported by applying zigzag encoding. |
void tkrzw::SleepThread | ( | double | sec | ) |
Sleeps the current thread.
sec | The duration in seconds to sleep for. |
double tkrzw::GetWallTime | ( | ) |
Gets the number of seconds since the UNIX epoch.
void tkrzw::GetLocalCalendar | ( | int64_t | wtime, |
struct std::tm * | cal | ||
) |
Gets the local calendar of a time.
wtime | the time since the UNIX epoch. |
cal | the pointer to a calendar object to store the result. |
void tkrzw::GetUniversalCalendar | ( | int64_t | wtime, |
struct std::tm * | cal | ||
) |
Gets the universal calendar of a time.
wtime | the time since the UNIX epoch. |
cal | the pointer to a calendar object to store the result. |
int64_t tkrzw::MakeUniversalTime | ( | struct std::tm & | cal | ) |
Makes the UNIX time from a universal calendar.
cal | the time struct of the universal calendar. |
int32_t tkrzw::GetLocalTimeDifference | ( | bool | use_cache = false | ) |
Gets the time difference of the local time zone.
use_cache | If true, the result of the first call is cached and reused for later calls. |
int32_t tkrzw::GetDayOfWeek | ( | int32_t | year, |
int32_t | mon, | ||
int32_t | day | ||
) |
Gets the day of week of a date.
year | the year of the date. |
mon | the month of the date. |
day | the day of the date. |
Formats a date as a simple string in "YYYY/MM/DD hh:mm:ss" format.
result | the pointer to the region into which the result string is written. The size of the buffer should be equal to or more than 48 bytes. |
wtime | the time since the UNIX epoch. If it is INT64MIN, the current time is specified. |
td | the time difference of the timze zone. If it is INT32MIN, the local time zone is specified. |
size_t tkrzw::FormatDateSimpleWithFrac | ( | char * | result, |
double | wtime = -1 , |
||
int32_t | td = INT32MIN , |
||
int32_t | frac_cols = 6 |
||
) |
Formats a date as a simple string in "YYYY/MM/DD hh:mm:ss" format.
result | the pointer to the region into which the result string is written. The size of the buffer should be equal to or more than 48 bytes. |
wtime | the time since the UNIX epoch. If it is negative, the current time is specified. |
td | the time difference of the timze zone. If it is INT32MIN, the local time zone is specified. |
frac_cols | The number of columns for the fraction part. |
Formats a date as a string in W3CDTF.
result | the pointer to the region into which the result string is written. The size of the buffer should be equal to or more than 48 bytes. |
wtime | the time since the UNIX epoch. If it is INT64MIN, the current time is specified. |
td | the time difference of the timze zone. If it is INT32MIN, the local time zone is specified. |
size_t tkrzw::FormatDateW3CDTFWithFrac | ( | char * | result, |
double | wtime = -1 , |
||
int32_t | td = INT32MIN , |
||
int32_t | frac_cols = 6 |
||
) |
Formats a date as a string in W3CDTF.
result | the pointer to the region into which the result string is written. The size of the buffer should be equal to or more than 48 bytes. |
wtime | the time since the UNIX epoch. If it is negative, the current time is specified. |
td | the time difference of the timze zone. If it is INT32MIN, the local time zone is specified. |
frac_cols | The number of columns for the fraction part. |
Formats a date as a string in RFC 1123 format.
result | the pointer to the region into which the result string is written. The size of the buffer should be equal to or more than 48 bytes. |
wtime | the time since the UNIX epoch. If it is INT64MIN, the current time is specified. |
td | the time difference of the timze zone. If it is INT32MIN, the local time zone is specified. |
double tkrzw::ParseDateStr | ( | std::string_view | str | ) |
Parses a date string to get the time value since the UNIX epoch.
str | the date string in decimal, hexadecimal, W3CDTF, or RFC 822 (1123). Decimal can be trailed by "s" for in seconds, "m" for in minutes, "h" for in hours, and "d" for in days. |
double tkrzw::ParseDateStrYYYYMMDD | ( | std::string_view | str, |
int32_t | td = INT32MIN |
||
) |
Parses a date string in "YYYYMMDD" to get the time value since the UNIX epoch.
str | the date string in "YYYYMMDD" or "YYMMDDhhmmss". As characters except for numbers are ignored, "YYYY-MM-DD" etc are also supported. |
td | the time difference of the timze zone. If it is INT32MIN, the local time zone is specified. |
std::string tkrzw::MakeRelativeTimeExpr | ( | double | diff | ) |
Makes a human-readable relative time expression of a time difference.
diff | The time difference in seconds. |
|
extern |
Directory separator character.
|
extern |
Directory separator string.
|
extern |
Extension separator character.
|
extern |
Extension separator string.
|
extern |
Current directory name.
|
extern |
Parent directory name.
|
constexpr |
Disable macros to avoid possible name confliction.
The minimum value of int8_t.
|
constexpr |
The maximum value of int8_t.
|
constexpr |
The maximum value of uint8_t.
|
constexpr |
The minimum value of int16_t.
|
constexpr |
The maximum value of int16_t.
|
constexpr |
The maximum value of uint16_t.
|
constexpr |
The minimum value of int32_t.
|
constexpr |
The maximum value of int32_t.
|
constexpr |
The maximum value of uint32_t.
|
constexpr |
The minimum value of int64_t.
|
constexpr |
The maximum value of int64_t.
|
constexpr |
The maximum value of uint64_t.
|
constexpr |
The maximum value of size_t.
|
constexpr |
The minimum value of float.
|
constexpr |
The maximum value of float.
|
constexpr |
The minimum value of double.
|
constexpr |
The maximum value of double.
|
constexpr |
The quiet Not-a-Number value of double.
|
constexpr |
The positive infinity value of double.
|
constexpr |
The buffer size for a numeric string expression.
|
constexpr |
The maximum memory size.
|
extern |
The size of a memory page on the OS.
|
extern |
The string expression of the package version.
|
extern |
The string expression of the library version.
|
extern |
The recognized OS name.
|
extern |
True if the OS is conforming to POSIX.
|
extern |
True if the byte order is big endian.