|
NX 1.0.3
niu2x's base c++ helper library
|
#include <string.h>#include <stdarg.h>#include <cstddef>#include <cstdint>#include <vector>#include <queue>#include <map>#include <type_traits>#include <unordered_map>#include <algorithm>#include <functional>#include <memory>#include <optional>#include <variant>#include <regex>#include <list>#include <chrono>#include <string>#include <stdexcept>#include <nx/api.h>

类 | |
| class | nx::Uncopyable |
| 用于被private继承, 子类将不可被Copy 更多... | |
| struct | nx::IO_Success |
| Result of successful io operation 更多... | |
| struct | nx::EndOfFile |
| End of file, a Unit struct. 更多... | |
| class | nx::Read |
| class | nx::Write |
| class | nx::MemoryFile |
命名空间 | |
| namespace | nx |
| root namespace | |
宏定义 | |
| #define | NX_PLATFORM_WINDOW 1 |
| #define | NX_PLATFORM_LINUX 2 |
| #define | NX_PLATFORM NX_PLATFORM_LINUX |
| #define | NX_PANIC(msg, ...) nx::panic_fmt(msg, ##__VA_ARGS__) |
| panic with a fatal error message. | |
| #define | NX_ASSERT(cond, msg, ...) |
| #define | NX_GET_BIT(x, bit) (((x) >> (bit)) & 1) |
| get bit flag | |
| #define | NX_SET_BIT(x, bit) ((x) | (1 << (bit))) |
| #define | NX_CLEAR_BIT(x, bit) ((x) & (~(1 << (bit)))) |
| #define | NX_GET_BIT_BOOL(x, bit) (NX_GET_BIT((x), (bit)) == 1) |
| get bit flag as boolean value | |
| #define | NX_SET_BIT_BOOL(x, bit, value) ((value) ? NX_SET_BIT((x), (bit)) : NX_CLEAR_BIT((x), (bit))) |
类型定义 | |
| using | nx::ByteBuffer = std::vector< uint8_t > |
| byte array | |
| template<class T > | |
| using | nx::Optional = std::optional< T > |
| template<class T > | |
| using | nx::Vector = std::vector< T > |
| template<class T > | |
| using | nx::Queue = std::queue< T > |
| using | nx::String = std::string |
| template<class... T> | |
| using | nx::Variant = std::variant< T... > |
| template<class T > | |
| using | nx::UniquePtr = std::unique_ptr< T > |
| template<class T > | |
| using | nx::SharedPtr = std::shared_ptr< T > |
| template<class K , class V > | |
| using | nx::Map = std::map< K, V > |
| template<class T > | |
| using | nx::Function = std::function< T > |
| template<class T > | |
| using | nx::List = std::list< T > |
| using | nx::ReadResult = Variant< IO_Error, EndOfFile, IO_Success > |
| Result of a read operation | |
| using | nx::ReadAllResult = Variant< IO_Error, ByteBuffer > |
| using | nx::WriteResult = Variant< IO_Error, IO_Success > |
| Result of a write operation | |
| using | nx::TimePoint = std::chrono::time_point< std::chrono::system_clock > |
| using | nx::TimeDuration = int64_t |
| milliseconds | |
枚举 | |
| enum class | nx::OpenMode { nx::WRITE , nx::READ } |
| Open Mode 更多... | |
| enum class | nx::IO_Error { nx::NOT_OPEN , nx::IO_FAIL } |
| IO Error 更多... | |
函数 | |
| NX_API void | nx::panic_fmt (const char *fmt,...) |
| constexpr size_t | nx::operator""_kb (unsigned long long int n) |
| NX_API bool | nx::pipe (Read &reader, Write &writer) |
| pipe data from reader to writer | |
| NX_API bool | nx::pipe (Read *reader, Write *writer) |
| TimePoint | nx::time_now () |
| get current clock time | |
| TimeDuration | nx::time_diff (const TimePoint &t_old, const TimePoint &t_new) |
| calculate time duration before old and now | |
| TimeDuration | nx::time_diff_epoch (const TimePoint &t) |
| uint8_t | nx::ceil_pow2 (uint8_t n) |
| uint16_t | nx::ceil_pow2 (uint16_t n) |
| uint32_t | nx::ceil_pow2 (uint32_t n) |
| uint64_t | nx::ceil_pow2 (uint64_t n) |
| template<class T > | |
| bool | nx::is_pow2 (T x) |
| NX_API ByteBuffer | nx::zlib_compress (const uint8_t *buf, size_t len) |
| NX_API ByteBuffer | nx::zlib_uncompress (const uint8_t *buf, size_t len) |
| #define NX_ASSERT | ( | cond, | |
| msg, | |||
| ... | |||
| ) |
| #define NX_CLEAR_BIT | ( | x, | |
| bit | |||
| ) | ((x) & (~(1 << (bit)))) |
| #define NX_GET_BIT | ( | x, | |
| bit | |||
| ) | (((x) >> (bit)) & 1) |
get bit flag
| x | the value |
| bit | The bit index |
| #define NX_GET_BIT_BOOL | ( | x, | |
| bit | |||
| ) | (NX_GET_BIT((x), (bit)) == 1) |
get bit flag as boolean value
| x | the value |
| bit | The bit index |
| #define NX_PANIC | ( | msg, | |
| ... | |||
| ) | nx::panic_fmt(msg, ##__VA_ARGS__) |
panic with a fatal error message.
| msg | The message |
| #define NX_PLATFORM NX_PLATFORM_LINUX |
| #define NX_PLATFORM_LINUX 2 |
| #define NX_PLATFORM_WINDOW 1 |
| #define NX_SET_BIT | ( | x, | |
| bit | |||
| ) | ((x) | (1 << (bit))) |
| #define NX_SET_BIT_BOOL | ( | x, | |
| bit, | |||
| value | |||
| ) | ((value) ? NX_SET_BIT((x), (bit)) : NX_CLEAR_BIT((x), (bit))) |