Adbase
Adinf C++ base library V2
adbase Namespace Reference

Namespaces

 detail
 
 head
 
 http
 
 kafka
 
 mc
 
 metrics
 
 sockets
 

Classes

class  Acceptor
 
class  AppendFile
 
class  AsyncLogging
 
class  Buffer
 Buffer 可以存取多种类型的数据,保证二进制安全,并且内存可以自动分配 More...
 
struct  ConnectionBaseInfo
 
class  Connector
 
class  Date
 日期工具类 More...
 
class  DuplicateOptionException
 
class  DuplicateSectionException
 
class  EventLoop
 
class  Fmt
 
class  InetAddress
 
class  IniConfig
 
class  IniParse
 
class  IniParseReadException
 
class  IniParseWriteException
 
class  InvalidOptionException
 
class  InvalidSectionException
 
class  LogFile
 
class  Logger
 
class  LogStream
 
class  Queue
 
class  ReadSmallFile
 
class  Sequence
 appid time seq mac 10 + 30 + 15 + 9 More...
 
class  Sha1
 实现 SHA1 算法 More...
 
class  Socket
 
class  T
 
class  TcpClient
 
class  TcpConnection
 
class  TcpServer
 
class  TcpWorker
 
class  Timer
 
class  TimerItem
 
class  Timestamp
 时间戳工具类 More...
 
class  TimeZone
 时区工具类 More...
 

Typedefs

typedef std::shared_ptr< ConnectorConnectorPtr
 
typedef std::shared_ptr< TimerItemTimerItemPtr
 
typedef std::shared_ptr< event_base > EventBasePtr
 libevent More...
 
typedef std::shared_ptr< bufferevent > BufferEventPtr
 
typedef std::shared_ptr< event > EventPtr
 
typedef struct adbase::ConnectionBaseInfo ConnectionBaseInfo
 
typedef std::shared_ptr< TcpConnectionTcpConnectionPtr
 
typedef std::function< void(const TcpConnectionPtr &)> ConnectionCallback
 
typedef std::function< void(const TcpConnectionPtr &)> CloseCallback
 
typedef std::function< void(int)> RemoveConnectionCallback
 
typedef std::function< void(const TcpConnectionPtr &)> WriteCompleteCallback
 
typedef std::function< std::string()> ConnectionCookiePrefix
 
typedef std::function< void(const TcpConnectionPtr &, size_t)> HighWaterMarkCallback
 
typedef std::function< void(const TcpConnectionPtr &, evbuffer *, Timestamp)> MessageCallback
 
typedef std::function< void(uint64_t)> DelTimerCallback
 
typedef std::function< void(void *)> TimerCallback
 

Functions

const char * strerror_tl (int saveErrno)
 
Logger::LogLevel initLogLevel ()
 
LogStreamoperator<< (LogStream &s, T v)
 
LogStreamoperator<< (LogStream &s, const Logger::SourceFile &v)
 
void defaultOutput (const char *msg, int len)
 
void defaultFlush ()
 
template<typename T >
TCheckNotNull (Logger::SourceFile file, int line, const char *names, T *ptr)
 
LogStreamoperator<< (LogStream &s, const Fmt &fmt)
 
bool operator< (Date x, Date y)
 
bool operator> (Date x, Date y)
 
bool operator== (Date x, Date y)
 
uint64_t hostToNetwork64 (uint64_t host64)
 uint64_t 的整形数字由机器字节序转化为网络字节序 More...
 
uint32_t hostToNetwork32 (uint32_t host32)
 uint32_t 的整形数字由机器字节序转化为网络字节序 More...
 
uint16_t hostToNetwork16 (uint16_t host16)
 uint16_t 的整形数字由机器字节序转化为网络字节序 More...
 
uint64_t networkToHost64 (uint64_t net64)
 uint64_t 的整形数字由网络字节序转化为机器字节序 More...
 
uint32_t networkToHost32 (uint32_t net32)
 uint32_t 的整形数字由网络字节序转化为机器字节序 More...
 
uint16_t networkToHost16 (uint16_t net16)
 uint16_t 的整形数字由网络字节序转化为机器字节序 More...
 
template int readFile (std::string filename, int maxSize, std::string *content, int64_t *, int64_t *, int64_t *)
 
void recursiveDir (std::string pathName, bool recursive, std::vector< std::string > excludes, std::vector< std::string > &pathInfo)
 递归遍历目录, 注意该函数禁止遍历根目录,并且目录中存在软链也忽略,只能遍历正常文件和目录 More...
 
bool mkdirRecursive (std::string pathName, int mode, bool recursive=true)
 递归创建目录 More...
 
template<typename S >
int readFile (std::string filename, int maxSize, S *context, int64_t *fileSize=nullptr, int64_t *modifyTime=nullptr, int64_t *createTime=nullptr)
 
pid_t pid ()
 获取进程ID More...
 
std::string pidString ()
 获取进程ID More...
 
std::string hostname ()
 获取主机名 More...
 
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > ifconfig ()
 获取主机的 ip 列表 More...
 
std::string procname ()
 获取进程名 More...
 
std::string procname (const std::string &stat)
 获取进程名 More...
 
std::string procStatus ()
 获取进程状态(可视化版) More...
 
std::string procStat ()
 获取进程状态 More...
 
const std::unordered_map< std::string, std::string > procStats ()
 获取当前进程的状态 More...
 
int procFdNum ()
 获取当前进程打开的文件数 More...
 
unsigned char toHex (unsigned char x)
 char to hex More...
 
unsigned char fromHex (unsigned char x)
 hex to char More...
 
void hexStringToBytes (const std::string &str, char *buffer)
 16进制字符串转化 bits More...
 
std::string bytesToHexString (const char *buffer, size_t length)
 bits 转化为16进制可见字符 More...
 
std::string urlEncode (const std::string &str)
 http url encode More...
 
std::string urlDecode (const std::string &str)
 http url decode More...
 
std::string base64Encode (const char *data, size_t len)
 base64 encode More...
 
void base64Decode (char *data, int *dataLen, const std::string &str)
 base64 decode More...
 
std::string encodeSegment (std::string id)
 
std::string base62Encode (uint64_t id)
 
std::string decodeSegment (const std::string &str)
 
uint64_t base62Decode (const std::string &str)
 
std::string rightTrim (const std::string &str, const char *trimStr=nullptr)
 从字符串右边 trim More...
 
std::string leftTrim (const std::string &str, const char *trimStr=nullptr)
 从字符串左边 trim More...
 
std::string trim (const std::string &str, const char *trimStr=nullptr)
 从字符串 trim More...
 
const std::vector< std::string > explode (const std::string &s, const char &c, bool isTrim=false)
 拆分字符串 More...
 
const std::string replace (const std::string &search, const std::string &replace, const std::string &subject, int &count)
 替换字符串 More...
 
bool operator< (Timestamp lhs, Timestamp rhs)
 比较两个 Timestamp 大小 More...
 
bool operator== (Timestamp lhs, Timestamp rhs)
 判断两个 Timestamp 是否相等 More...
 
double timeDifference (Timestamp high, Timestamp low)
 求两个 Timestamp 的差值 More...
 
Timestamp addTime (Timestamp timestamp, double seconds)
 

Variables

thread_local char tErrnoBuf [512]
 
thread_local char tTime [32]
 
thread_local time_t tLastSecond
 
Logger::LogLevel gLogLevel = initLogLevel()
 
const char * LogLevelName [Logger::NUM_LOG_LEVELS]
 
Logger::OutputFunc gOutput = std::bind(&defaultOutput, std::placeholders::_1, std::placeholders::_2)
 
Logger::FlushFunc gFlush = std::bind(&defaultFlush)
 
TimeZone gLogTimeZone
 
static const in_addr_t kInaddrAny = INADDR_ANY
 
static const in_addr_t kInaddrLoopback = INADDR_LOOPBACK
 
const std::string TRIM_DELIMITERS = " \f\n\r\t\v"
 
const int kSecondsPerDay = 24*60*60
 

Typedef Documentation

typedef std::shared_ptr<bufferevent> adbase::BufferEventPtr

Definition at line 16 of file Types.hpp.

typedef std::function<void (const TcpConnectionPtr&)> adbase::CloseCallback

Definition at line 31 of file Types.hpp.

typedef std::function<void (const TcpConnectionPtr&)> adbase::ConnectionCallback

Definition at line 30 of file Types.hpp.

typedef std::function<std::string ()> adbase::ConnectionCookiePrefix

Definition at line 34 of file Types.hpp.

typedef std::function<void (uint64_t)> adbase::DelTimerCallback

Definition at line 47 of file Types.hpp.

typedef std::shared_ptr<event_base> adbase::EventBasePtr

libevent

Definition at line 15 of file Types.hpp.

typedef std::shared_ptr<event> adbase::EventPtr

Definition at line 17 of file Types.hpp.

typedef std::function<void (const TcpConnectionPtr&, size_t)> adbase::HighWaterMarkCallback

Definition at line 35 of file Types.hpp.

typedef std::function<void (const TcpConnectionPtr&, evbuffer*, Timestamp)> adbase::MessageCallback

Definition at line 38 of file Types.hpp.

typedef std::function<void (int)> adbase::RemoveConnectionCallback

Definition at line 32 of file Types.hpp.

typedef std::shared_ptr<TcpConnection> adbase::TcpConnectionPtr

Definition at line 28 of file Types.hpp.

typedef std::function<void (void*)> adbase::TimerCallback

Definition at line 48 of file Types.hpp.

typedef std::function<void (const TcpConnectionPtr&)> adbase::WriteCompleteCallback

Definition at line 33 of file Types.hpp.

Function Documentation

void adbase::defaultFlush ( )

Definition at line 69 of file Logging.cpp.

void adbase::defaultOutput ( const char *  msg,
int  len 
)

Definition at line 64 of file Logging.cpp.

Logger::LogLevel adbase::initLogLevel ( )

Definition at line 21 of file Logging.cpp.

References adbase::Logger::DEBUG, adbase::Logger::INFO, and adbase::Logger::TRACE.

LogStream& adbase::operator<< ( LogStream s,
T  v 
)
inline

Definition at line 54 of file Logging.cpp.

References adbase::T::_len, adbase::T::_str, and adbase::LogStream::append().

Referenced by adbase::LogStream::operator<<().

LogStream& adbase::operator<< ( LogStream s,
const Logger::SourceFile v 
)
inline
template int adbase::readFile ( std::string  filename,
int  maxSize,
std::string *  content,
int64_t *  ,
int64_t *  ,
int64_t *   
)

Variable Documentation

Logger::FlushFunc adbase::gFlush = std::bind(&defaultFlush)

Definition at line 74 of file Logging.cpp.

Referenced by adbase::Logger::~Logger().

TimeZone adbase::gLogTimeZone

Definition at line 75 of file Logging.cpp.

Logger::OutputFunc adbase::gOutput = std::bind(&defaultOutput, std::placeholders::_1, std::placeholders::_2)

Definition at line 73 of file Logging.cpp.

Referenced by adbase::Logger::~Logger().

const in_addr_t adbase::kInaddrAny = INADDR_ANY
static

Definition at line 13 of file InetAddress.cpp.

Referenced by adbase::InetAddress::InetAddress().

const in_addr_t adbase::kInaddrLoopback = INADDR_LOOPBACK
static

Definition at line 14 of file InetAddress.cpp.

const int adbase::kSecondsPerDay = 24*60*60

Definition at line 71 of file TimeZone.cpp.

Referenced by adbase::TimeZone::toUtcTime().

const char* adbase::LogLevelName[Logger::NUM_LOG_LEVELS]
Initial value:
= {
"TRACE ",
"DEBUG ",
"INFO ",
"WARN ",
"ERROR ",
"FATAL ",
}

Definition at line 33 of file Logging.cpp.

thread_local char adbase::tErrnoBuf[512]

Definition at line 13 of file Logging.cpp.

thread_local time_t adbase::tLastSecond

Definition at line 15 of file Logging.cpp.

const std::string adbase::TRIM_DELIMITERS = " \f\n\r\t\v"

Definition at line 5 of file String.cpp.

thread_local char adbase::tTime[32]

Definition at line 14 of file Logging.cpp.