16 #ifndef INCLUDE_NN_NLIB_MSGPACK_MPWALKER_H_ 17 #define INCLUDE_NN_NLIB_MSGPACK_MPWALKER_H_ 21 #include "nn/nlib/Swap.h" 23 #ifdef NLIB_CXX11_STDLIB_TUPLE 27 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 28 #undef NLIB_VIS_PUBLIC 29 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 40 cur_(static_cast<const uint8_t*>(p)), size_(n) {}
43 cur_ =
static_cast<const uint8_t*
>(p);
54 return operator[](static_cast<size_t>(array_idx));
59 size_t GetSize() const NLIB_NOEXCEPT {
return size_; }
80 #ifdef NLIB_CXX11_STDLIB_TUPLE 81 std::tuple<MpWalker, const nlib_utf8_t*, uint32_t>
82 GetString()
const NLIB_NOEXCEPT {
83 std::tuple<MpWalker, const nlib_utf8_t*, uint32_t> rval;
84 std::get<0>(rval) = GetString(&std::get<1>(rval), &std::get<2>(rval));
87 std::tuple<MpWalker, const nlib_byte_t*, uint32_t>
88 GetBinary()
const NLIB_NOEXCEPT {
89 std::tuple<MpWalker, const nlib_byte_t*, uint32_t> rval;
90 std::get<0>(rval) = GetBinary(reinterpret_cast<const void**>(&std::get<1>(rval)),
94 std::tuple<MpWalker, int8_t, const nlib_byte_t*, uint32_t>
95 GetExt()
const NLIB_NOEXCEPT {
96 std::tuple<MpWalker, int8_t, const nlib_byte_t*, uint32_t> rval;
97 std::get<0>(rval) = GetExt(&std::get<1>(rval),
98 reinterpret_cast<const void**
>(&std::get<2>(rval)),
103 std::pair<MpWalker, uint32_t>
104 GetMapCount()
const NLIB_NOEXCEPT {
105 std::pair<MpWalker, uint32_t> rval;
106 rval.first = GetMapCount(&rval.second);
109 std::pair<MpWalker, uint32_t>
110 GetArrayCount()
const NLIB_NOEXCEPT {
111 std::pair<MpWalker, uint32_t> rval;
112 rval.first = GetArrayCount(&rval.second);
115 std::pair<MpWalker, bool>
116 GetBoolean()
const NLIB_NOEXCEPT {
117 std::pair<MpWalker, bool> rval;
118 rval.first = GetBoolean(&rval.second);
121 std::pair<MpWalker, int32_t>
122 GetInt32()
const NLIB_NOEXCEPT {
123 std::pair<MpWalker, int32_t> rval;
124 rval.first = GetInt(&rval.second);
127 std::pair<MpWalker, int64_t>
128 GetInt64()
const NLIB_NOEXCEPT {
129 std::pair<MpWalker, int64_t> rval;
130 rval.first = GetInt(&rval.second);
133 std::pair<MpWalker, uint32_t>
134 GetUint32()
const NLIB_NOEXCEPT {
135 std::pair<MpWalker, uint32_t> rval;
136 rval.first = GetUint(&rval.second);
139 std::pair<MpWalker, uint64_t>
140 GetUint64()
const NLIB_NOEXCEPT {
141 std::pair<MpWalker, uint64_t> rval;
142 rval.first = GetUint(&rval.second);
145 std::pair<MpWalker, float>
146 GetFloat()
const NLIB_NOEXCEPT {
147 std::pair<MpWalker, float> rval;
148 rval.first = GetFloat(&rval.second);
151 std::pair<MpWalker, double>
152 GetDouble()
const NLIB_NOEXCEPT {
153 std::pair<MpWalker, double> rval;
154 rval.first = GetDouble(&rval.second);
157 std::pair<MpWalker, nlib_time>
158 GetTimestamp()
const NLIB_NOEXCEPT {
159 std::pair<MpWalker, nlib_time> rval;
160 rval.first = GetTimestamp(&rval.second);
166 bool IsOk()
const NLIB_NOEXCEPT {
return cur_ !=
nullptr; }
175 #if defined(_MSC_VER) && defined(nx_msgpack_EXPORTS) 176 #undef NLIB_VIS_PUBLIC 177 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 180 #endif // INCLUDE_NN_NLIB_MSGPACK_MPWALKER_H_ #define NLIB_SAFE_BOOL(class_name, exp)
クラス内に安全なoperator bool()を定義します。 可能であればC++11のexplicit boolを利用します。 ...
constexpr MpWalker() noexcept
デフォルトコンストラクタです。
size_t GetSize() const noexcept
MessagePackデータのサイズを取得します。
MpWalker operator[](int array_idx) const noexcept
operator[](size_t array_idx) と同様です。
const nlib_byte_t * GetPtr() const noexcept
MessagePackデータの現在位置へのポインタを取得します。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
メモリ上に展開されたMessagePackのデータに高速にアクセスします。
bool Init(const void *p, size_t n) noexcept
デフォルトコンストラクタを利用した場合はこの関数で初期化します。
constexpr MpWalker(const void *p, size_t n) noexcept
コンストラクタです。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。