NX 1.0.3
niu2x's base c++ helper library
载入中...
搜索中...
未找到
命名空间 | | 类型定义 | 枚举 | 函数
nx 命名空间参考

root namespace 更多...

命名空间

namespace  cmd
 
namespace  digest
 digest namespace
 
namespace  file_system
 file_system namespace
 
namespace  logging
 

struct  EndOfFile
 End of file, a Unit struct. 更多...
 
struct  IO_Success
 Result of successful io operation 更多...
 
class  MemoryFile
 
class  Read
 
class  Uncopyable
 用于被private继承, 子类将不可被Copy 更多...
 
class  Write
 

类型定义

using CRC32 = nx::digest::CRC32
 
using MD5 = nx::digest::MD5
 
using SHA256 = nx::digest::SHA256
 
using ByteBuffer = std::vector< uint8_t >
 byte array
 
template<class T >
using Optional = std::optional< T >
 
template<class T >
using Vector = std::vector< T >
 
template<class T >
using Queue = std::queue< T >
 
using String = std::string
 
template<class... T>
using Variant = std::variant< T... >
 
template<class T >
using UniquePtr = std::unique_ptr< T >
 
template<class T >
using SharedPtr = std::shared_ptr< T >
 
template<class K , class V >
using Map = std::map< K, V >
 
template<class T >
using Function = std::function< T >
 
template<class T >
using List = std::list< T >
 
using ReadResult = Variant< IO_Error, EndOfFile, IO_Success >
 Result of a read operation
 
using ReadAllResult = Variant< IO_Error, ByteBuffer >
 
using WriteResult = Variant< IO_Error, IO_Success >
 Result of a write operation
 
using TimePoint = std::chrono::time_point< std::chrono::system_clock >
 
using TimeDuration = int64_t
 milliseconds
 

枚举

enum class  OpenMode { WRITE , READ }
 Open Mode 更多...
 
enum class  IO_Error { NOT_OPEN , IO_FAIL }
 IO Error 更多...
 

函数

NX_API void panic_fmt (const char *fmt,...)
 
constexpr size_t operator""_kb (unsigned long long int n)
 
NX_API bool pipe (Read &reader, Write &writer)
 pipe data from reader to writer
 
NX_API bool pipe (Read *reader, Write *writer)
 
TimePoint time_now ()
 get current clock time
 
TimeDuration time_diff (const TimePoint &t_old, const TimePoint &t_new)
 calculate time duration before old and now
 
TimeDuration time_diff_epoch (const TimePoint &t)
 
uint8_t ceil_pow2 (uint8_t n)
 
uint16_t ceil_pow2 (uint16_t n)
 
uint32_t ceil_pow2 (uint32_t n)
 
uint64_t ceil_pow2 (uint64_t n)
 
template<class T >
bool is_pow2 (T x)
 
NX_API ByteBuffer zlib_compress (const uint8_t *buf, size_t len)
 
NX_API ByteBuffer zlib_uncompress (const uint8_t *buf, size_t len)
 

详细描述

root namespace

类型定义说明

◆ ByteBuffer

using nx::ByteBuffer = typedef std::vector<uint8_t>

byte array

◆ CRC32

using nx::CRC32 = typedef nx::digest::CRC32

◆ Function

template<class T >
using nx::Function = typedef std::function<T>

◆ List

template<class T >
using nx::List = typedef std::list<T>

◆ Map

template<class K , class V >
using nx::Map = typedef std::map<K, V>

◆ MD5

using nx::MD5 = typedef nx::digest::MD5

◆ Optional

template<class T >
using nx::Optional = typedef std::optional<T>

◆ Queue

template<class T >
using nx::Queue = typedef std::queue<T>

◆ ReadAllResult

◆ ReadResult

Result of a read operation

◆ SHA256

using nx::SHA256 = typedef nx::digest::SHA256

◆ SharedPtr

template<class T >
using nx::SharedPtr = typedef std::shared_ptr<T>

◆ String

using nx::String = typedef std::string

◆ TimeDuration

using nx::TimeDuration = typedef int64_t

milliseconds

◆ TimePoint

using nx::TimePoint = typedef std::chrono::time_point<std::chrono::system_clock>

◆ UniquePtr

template<class T >
using nx::UniquePtr = typedef std::unique_ptr<T>

◆ Variant

template<class... T>
using nx::Variant = typedef std::variant<T...>

◆ Vector

template<class T >
using nx::Vector = typedef std::vector<T>

◆ WriteResult

Result of a write operation

枚举类型说明

◆ IO_Error

enum class nx::IO_Error
strong

IO Error

枚举值
NOT_OPEN 
IO_FAIL 

◆ OpenMode

enum class nx::OpenMode
strong

Open Mode

枚举值
WRITE 
READ 

函数说明

◆ ceil_pow2() [1/4]

uint16_t nx::ceil_pow2 ( uint16_t  n)
inline

◆ ceil_pow2() [2/4]

uint32_t nx::ceil_pow2 ( uint32_t  n)
inline

◆ ceil_pow2() [3/4]

uint64_t nx::ceil_pow2 ( uint64_t  n)
inline

◆ ceil_pow2() [4/4]

uint8_t nx::ceil_pow2 ( uint8_t  n)
inline

◆ is_pow2()

template<class T >
bool nx::is_pow2 ( x)
inline

◆ operator""_kb()

constexpr size_t nx::operator""_kb ( unsigned long long int  n)
constexpr

◆ panic_fmt()

NX_API void nx::panic_fmt ( const char *  fmt,
  ... 
)

◆ pipe() [1/2]

NX_API bool nx::pipe ( Read reader,
Write writer 
)

pipe data from reader to writer

参数
readerThe reader
writerThe writer
返回
success?

◆ pipe() [2/2]

NX_API bool nx::pipe ( Read reader,
Write writer 
)

◆ time_diff()

TimeDuration nx::time_diff ( const TimePoint t_old,
const TimePoint t_new 
)
inline

calculate time duration before old and now

参数
[in]t_oldThe old timepoint
[in]t_newThe now timepoint
返回
The time duration.

◆ time_diff_epoch()

TimeDuration nx::time_diff_epoch ( const TimePoint t)
inline

◆ time_now()

TimePoint nx::time_now ( )
inline

get current clock time

返回
The time point.

◆ zlib_compress()

NX_API ByteBuffer nx::zlib_compress ( const uint8_t *  buf,
size_t  len 
)

◆ zlib_uncompress()

NX_API ByteBuffer nx::zlib_uncompress ( const uint8_t *  buf,
size_t  len 
)