|
Adbase
Adinf C++ base library V2
|
adbase 基础通用工具(使用方法见该模块的描述信息) More...
Classes | |
| class | adbase::Buffer |
| Buffer 可以存取多种类型的数据,保证二进制安全,并且内存可以自动分配 More... | |
| class | adbase::Date |
| 日期工具类 More... | |
| class | adbase::ReadSmallFile |
| class | adbase::AppendFile |
| class | adbase::Queue< T > |
| class | adbase::Sequence |
| appid time seq mac 10 + 30 + 15 + 9 More... | |
| class | adbase::Sha1 |
| 实现 SHA1 算法 More... | |
| class | adbase::Timestamp |
| 时间戳工具类 More... | |
| class | adbase::TimeZone |
| 时区工具类 More... | |
Macros | |
| #define | SEQUENCE_BASE_TIME 1451577600 |
Functions | |
| bool | adbase::operator< (Date x, Date y) |
| bool | adbase::operator> (Date x, Date y) |
| bool | adbase::operator== (Date x, Date y) |
| uint64_t | adbase::hostToNetwork64 (uint64_t host64) |
| uint64_t 的整形数字由机器字节序转化为网络字节序 More... | |
| uint32_t | adbase::hostToNetwork32 (uint32_t host32) |
| uint32_t 的整形数字由机器字节序转化为网络字节序 More... | |
| uint16_t | adbase::hostToNetwork16 (uint16_t host16) |
| uint16_t 的整形数字由机器字节序转化为网络字节序 More... | |
| uint64_t | adbase::networkToHost64 (uint64_t net64) |
| uint64_t 的整形数字由网络字节序转化为机器字节序 More... | |
| uint32_t | adbase::networkToHost32 (uint32_t net32) |
| uint32_t 的整形数字由网络字节序转化为机器字节序 More... | |
| uint16_t | adbase::networkToHost16 (uint16_t net16) |
| uint16_t 的整形数字由网络字节序转化为机器字节序 More... | |
| template<typename S > | |
| int | adbase::readFile (std::string filename, int maxSize, S *context, int64_t *fileSize=nullptr, int64_t *modifyTime=nullptr, int64_t *createTime=nullptr) |
| void | adbase::recursiveDir (std::string pathName, bool recursive, std::vector< std::string > excludes, std::vector< std::string > &pathInfo) |
| 递归遍历目录, 注意该函数禁止遍历根目录,并且目录中存在软链也忽略,只能遍历正常文件和目录 More... | |
| bool | adbase::mkdirRecursive (std::string pathName, int mode, bool recursive=true) |
| 递归创建目录 More... | |
| pid_t | adbase::pid () |
| 获取进程ID More... | |
| std::string | adbase::pidString () |
| 获取进程ID More... | |
| std::string | adbase::hostname () |
| 获取主机名 More... | |
| std::unordered_map< std::string, std::unordered_map< std::string, std::string > > | adbase::ifconfig () |
| 获取主机的 ip 列表 More... | |
| std::string | adbase::procname () |
| 获取进程名 More... | |
| std::string | adbase::procname (const std::string &stat) |
| 获取进程名 More... | |
| std::string | adbase::procStatus () |
| 获取进程状态(可视化版) More... | |
| std::string | adbase::procStat () |
| 获取进程状态 More... | |
| const std::unordered_map< std::string, std::string > | adbase::procStats () |
| 获取当前进程的状态 More... | |
| int | adbase::procFdNum () |
| 获取当前进程打开的文件数 More... | |
| std::string | adbase::urlEncode (const std::string &str) |
| http url encode More... | |
| std::string | adbase::urlDecode (const std::string &str) |
| http url decode More... | |
| std::string | adbase::base64Encode (const char *data, size_t len) |
| base64 encode More... | |
| void | adbase::base64Decode (char *data, int *dataLen, const std::string &str) |
| base64 decode More... | |
| unsigned char | adbase::toHex (unsigned char x) |
| char to hex More... | |
| unsigned char | adbase::fromHex (unsigned char x) |
| hex to char More... | |
| void | adbase::hexStringToBytes (const std::string &str, char *buffer) |
| 16进制字符串转化 bits More... | |
| std::string | adbase::bytesToHexString (const char *buffer, size_t length) |
| bits 转化为16进制可见字符 More... | |
| std::string | adbase::base62Encode (uint64_t id) |
| uint64_t | adbase::base62Decode (const std::string &str) |
| std::string | adbase::encodeSegment (std::string id) |
| std::string | adbase::decodeSegment (const std::string &str) |
| std::string | adbase::leftTrim (const std::string &str, const char *trimStr=nullptr) |
| 从字符串左边 trim More... | |
| std::string | adbase::rightTrim (const std::string &str, const char *trimStr=nullptr) |
| 从字符串右边 trim More... | |
| std::string | adbase::trim (const std::string &str, const char *trimStr=nullptr) |
| 从字符串 trim More... | |
| const std::vector< std::string > | adbase::explode (const std::string &s, const char &c, bool isTrim=false) |
| 拆分字符串 More... | |
| const std::string | adbase::replace (const std::string &search, const std::string &replace, const std::string &subject, int &count) |
| 替换字符串 More... | |
| bool | adbase::operator< (Timestamp lhs, Timestamp rhs) |
| 比较两个 Timestamp 大小 More... | |
| bool | adbase::operator== (Timestamp lhs, Timestamp rhs) |
| 判断两个 Timestamp 是否相等 More... | |
| double | adbase::timeDifference (Timestamp high, Timestamp low) |
| 求两个 Timestamp 的差值 More... | |
| Timestamp | adbase::addTime (Timestamp timestamp, double seconds) |
adbase 基础通用工具(使用方法见该模块的描述信息)
| #define SEQUENCE_BASE_TIME 1451577600 |
Definition at line 16 of file Sequence.hpp.
Referenced by adbase::Sequence::getSeqId().
|
inline |
Definition at line 195 of file Timestamp.hpp.
References adbase::Timestamp::kMicroSecondsPerSecond, adbase::Timestamp::microSecondsSinceEpoch(), and adbase::Timestamp::Timestamp().
| uint64_t adbase::base62Decode | ( | const std::string & | str | ) |
Definition at line 271 of file Serialize.cpp.
References DECODEBLOCKSIZE, adbase::decodeSegment(), and ENCODEBLOCKSIZE.
| std::string adbase::base62Encode | ( | uint64_t | id | ) |
Definition at line 232 of file Serialize.cpp.
References DECODEBLOCKSIZE, ENCODEBLOCKSIZE, and adbase::encodeSegment().
| void adbase::base64Decode | ( | char * | data, |
| int * | dataLen, | ||
| const std::string & | str | ||
| ) |
base64 decode
| data | decode result |
| dataLen | decode data length |
| str | decode string |
| none |
Definition at line 155 of file Serialize.cpp.
| std::string adbase::base64Encode | ( | const char * | data, |
| size_t | len | ||
| ) |
base64 encode
| data | encode data |
| len | encode data length |
| none |
Definition at line 111 of file Serialize.cpp.
| std::string adbase::bytesToHexString | ( | const char * | buffer, |
| size_t | length | ||
| ) |
bits 转化为16进制可见字符
| buffer | 要转化的 bits |
| length | 要转化的 bits 的长度 |
Definition at line 47 of file Serialize.cpp.
| std::string adbase::decodeSegment | ( | const std::string & | str | ) |
Definition at line 256 of file Serialize.cpp.
Referenced by adbase::base62Decode().
| std::string adbase::encodeSegment | ( | std::string | id | ) |
Definition at line 208 of file Serialize.cpp.
Referenced by adbase::base62Encode().
| const std::vector< std::string > adbase::explode | ( | const std::string & | s, |
| const char & | c, | ||
| bool | isTrim = false |
||
| ) |
拆分字符串
| s | 要拆分的字符串 |
| c | 分隔符 |
| isTrim | 是否将拆分的字符串做 trim 操作 |
| none |
Definition at line 41 of file String.cpp.
References adbase::trim().
Referenced by adbase::mc::ClientHandler::get(), adbase::metrics::Metrics::getMetricName(), adbase::IniParse::load(), adbase::mc::Ascii::processData(), and adbase::procStats().
| unsigned char adbase::fromHex | ( | unsigned char | x | ) |
hex to char
Definition at line 16 of file Serialize.cpp.
Referenced by adbase::hexStringToBytes(), and adbase::urlDecode().
| void adbase::hexStringToBytes | ( | const std::string & | str, |
| char * | buffer | ||
| ) |
16进制字符串转化 bits
| str | 需要转化的 16 进制字符串 |
| buffer | 转化结果 |
Definition at line 35 of file Serialize.cpp.
References adbase::fromHex().
| std::string adbase::hostname | ( | ) |
获取主机名
Definition at line 39 of file ProcessInfo.cpp.
Referenced by adbase::InetAddress::portNetEndian(), and adbase::LogFile::rollFile().
|
inline |
uint16_t 的整形数字由机器字节序转化为网络字节序
| host16 | 需要转化的数据 |
| none |
Definition at line 108 of file Endian.hpp.
Referenced by adbase::Buffer::appendInt16(), adbase::sockets::fromIpPort(), adbase::mc::ClientHandler::get(), adbase::InetAddress::InetAddress(), adbase::Buffer::prependInt16(), adbase::head::Binary::processData(), and adbase::mc::Binary::processData().
|
inline |
uint32_t 的整形数字由机器字节序转化为网络字节序
| host32 | 需要转化的数据 |
| none |
Definition at line 91 of file Endian.hpp.
Referenced by adbase::Buffer::appendInt32(), adbase::mc::ClientHandler::get(), adbase::InetAddress::InetAddress(), adbase::Buffer::prependInt32(), adbase::head::Binary::processData(), and adbase::mc::Binary::processData().
|
inline |
uint64_t 的整形数字由机器字节序转化为网络字节序
| host64 | 需要转化的数据 |
| none |
Definition at line 74 of file Endian.hpp.
Referenced by adbase::Buffer::appendInt64(), adbase::Buffer::prependInt64(), and adbase::mc::Binary::processData().
| std::unordered_map< std::string, std::unordered_map< std::string, std::string > > adbase::ifconfig | ( | ) |
| std::string adbase::leftTrim | ( | const std::string & | str, |
| const char * | trimStr | ||
| ) |
从字符串左边 trim
Definition at line 20 of file String.cpp.
Referenced by adbase::trim(), and adbase::IniParse::write().
| bool adbase::mkdirRecursive | ( | std::string | pathName, |
| int | mode, | ||
| bool | recursive | ||
| ) |
递归创建目录
Definition at line 228 of file FileSystem.cpp.
Referenced by adbase::AppendFile::writtenBytes().
|
inline |
uint16_t 的整形数字由网络字节序转化为机器字节序
| net16 | 需要转化的数据 |
| none |
Definition at line 159 of file Endian.hpp.
Referenced by adbase::mc::ClientHandler::get(), adbase::Buffer::peekInt16(), adbase::mc::Binary::processData(), adbase::sockets::toIpPort(), and adbase::InetAddress::toPort().
|
inline |
uint32_t 的整形数字由网络字节序转化为机器字节序
| net32 | 需要转化的数据 |
| none |
Definition at line 142 of file Endian.hpp.
Referenced by adbase::mc::ClientHandler::get(), adbase::Buffer::peekInt32(), adbase::head::Binary::processData(), adbase::mc::Binary::processData(), and adbase::detail::File::readInt32().
|
inline |
uint64_t 的整形数字由网络字节序转化为机器字节序
| net64 | 需要转化的数据 |
| none |
Definition at line 125 of file Endian.hpp.
Referenced by adbase::Buffer::peekInt64(), and adbase::mc::Binary::processData().
比较两个 Timestamp 大小
Definition at line 170 of file Timestamp.hpp.
References adbase::Timestamp::microSecondsSinceEpoch().
判断两个 Timestamp 是否相等
Definition at line 180 of file Timestamp.hpp.
References adbase::Timestamp::microSecondsSinceEpoch().
| pid_t adbase::pid | ( | ) |
获取进程ID
Definition at line 23 of file ProcessInfo.cpp.
Referenced by adbase::pidString(), and adbase::LogFile::rollFile().
| std::string adbase::pidString | ( | ) |
| int adbase::procFdNum | ( | ) |
获取当前进程打开的文件数
Definition at line 183 of file ProcessInfo.cpp.
References adbase::recursiveDir().
Referenced by adbase::procStats().
| std::string adbase::procname | ( | ) |
| std::string adbase::procname | ( | const std::string & | stat | ) |
获取进程名
Definition at line 107 of file ProcessInfo.cpp.
| std::string adbase::procStat | ( | ) |
获取进程状态
Definition at line 129 of file ProcessInfo.cpp.
References adbase::readFile().
Referenced by adbase::procname(), and adbase::procStats().
| const std::unordered_map< std::string, std::string > adbase::procStats | ( | ) |
获取当前进程的状态
Definition at line 138 of file ProcessInfo.cpp.
References ADBASE_SOVERSION, ADBASE_VERSION, adbase::explode(), adbase::procFdNum(), and adbase::procStat().
| std::string adbase::procStatus | ( | ) |
| int adbase::readFile | ( | std::string | filename, |
| int | maxSize, | ||
| S * | context, | ||
| int64_t * | fileSize = nullptr, |
||
| int64_t * | modifyTime = nullptr, |
||
| int64_t * | createTime = nullptr |
||
| ) |
Definition at line 51 of file FileSystem.hpp.
References adbase::ReadSmallFile::readToString().
| void adbase::recursiveDir | ( | std::string | pathName, |
| bool | recursive, | ||
| std::vector< std::string > | excludes, | ||
| std::vector< std::string > & | pathInfo | ||
| ) |
递归遍历目录, 注意该函数禁止遍历根目录,并且目录中存在软链也忽略,只能遍历正常文件和目录
Definition at line 171 of file FileSystem.cpp.
Referenced by adbase::procFdNum(), and adbase::AppendFile::writtenBytes().
| const std::string adbase::replace | ( | const std::string & | search, |
| const std::string & | replace, | ||
| const std::string & | subject, | ||
| int & | count | ||
| ) |
替换字符串
| search | 要替换搜索的字符串 |
| replace | 要替换的子字符串 |
| subject | 替换文本 |
| count | 替换的次数 |
| none |
Definition at line 68 of file String.cpp.
Referenced by adbase::http::Server::setLocationFallback().
| std::string adbase::rightTrim | ( | const std::string & | str, |
| const char * | trimStr | ||
| ) |
求两个 Timestamp 的差值
Definition at line 190 of file Timestamp.hpp.
References adbase::Timestamp::kMicroSecondsPerSecond, and adbase::Timestamp::microSecondsSinceEpoch().
| unsigned char adbase::toHex | ( | unsigned char | x | ) |
| std::string adbase::trim | ( | const std::string & | str, |
| const char * | trimStr | ||
| ) |
从字符串 trim
Definition at line 34 of file String.cpp.
References adbase::leftTrim(), and adbase::rightTrim().
Referenced by adbase::explode(), adbase::mc::Ascii::processData(), adbase::http::Server::registerLocation(), and adbase::IniParse::write().
| std::string adbase::urlDecode | ( | const std::string & | str | ) |
http url decode
| str | decode url |
| none |
Definition at line 89 of file Serialize.cpp.
References adbase::fromHex().
| std::string adbase::urlEncode | ( | const std::string & | str | ) |
http url encode
| str | encode url |
| none |
Definition at line 63 of file Serialize.cpp.
References adbase::toHex().