Motr
M0
|
#include "lib/errno.h"
#include "lib/assert.h"
#include "lib/memory.h"
#include "lib/arith.h"
#include "lib/string.h"
#include "xcode/xcode.h"
#include "lib/trace.h"
Go to the source code of this file.
Macros | |
#define | M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_XCODE |
#define | P(...) ({ nob += snprintf(str + nob, max64(nr - nob, 0), __VA_ARGS__); }) |
#define | PCHAR(ch) ({ char _ch = (ch); if (_ch != 0) P("%c", _ch); }) |
Functions | |
M0_INTERNAL const char * | space_skip (const char *str) |
static int | string_literal (const struct m0_xcode_cursor *it, struct m0_xcode_obj *obj, const char *str) |
static int | char_check (const char **str, char ch) |
static char | punctchar (struct m0_xcode_cursor *it) |
M0_INTERNAL int | m0_xcode_read (struct m0_xcode_obj *obj, const char *str) |
static bool | quoted_string (const struct m0_xcode_type *xt, const struct m0_xcode_obj *obj, struct m0_fop_str *qstr) |
M0_INTERNAL int | m0_xcode_print (const struct m0_xcode_obj *obj, char *str, int nr) |
xcoding. | |
Encoding-decoding (collectively xcoding) support is implemented on top of introspection facilities provided by the xcode module. xcoding provides 3 operations: - sizing (m0_xcode_length()): returns the size of a buffer sufficient to hold serialized object representation; - encoding (m0_xcode_encode()): constructs a serialized object representation in a given buffer; - decoding (m0_xcode_decode()): constructs an in-memory object, given its serialized representation. xcoding traverses the tree of sub-objects, starting from the topmost object to be xcoded. For each visited object, if a method, corresponding to the xcoding operation (encode, decode, length) is not NULL in object's type m0_xcode_type_ops vector, this method is called and no further processing of this object is done. Otherwise, "standard xcoding" takes place. Standard xcoding is non-trivial only for leaves in the sub-object tree (i.e., for objects of ATOM aggregation type): - for encoding, place object's value into the buffer, convert it to desired endianness and advance buffer position; - for decoding, extract value from the buffer, convert it, store in the in-memory object and advance buffer position; - for sizing, increment required buffer size by the size of atomic type. In addition, decoding allocates memory as necessary. | |
M0_EXTERN ssize_t | m0_xcode_alloc_obj (struct m0_xcode_cursor *it, void *(*alloc)(struct m0_xcode_cursor *, size_t)) |
Variables | |
static int(*)(const struct m0_xcode_cursor *, struct m0_xcode_obj *, const char *) | field_reader (const struct m0_xcode_cursor *it) |
static const char | structure [M0_XA_NR][M0_XCODE_CURSOR_NR] |
static const char | punctuation [M0_XA_NR][3] |