WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
mpack.h File Reference

Abstracts all platform-specific code from MPack and handles configuration options. More...

Go to the source code of this file.

Macros

#define MPACK_AMALGAMATED   1
 The MIT License (MIT)
 
#define MPACK_PLATFORM_H   1
 
#define MPACK_COMMON_H   1
 
#define MPACK_PRINT_BYTE_COUNT   12
 
#define MPACK_VERSION_MAJOR   1
 The major version number of MPack.
 
#define MPACK_VERSION_MINOR   1
 The minor version number of MPack.
 
#define MPACK_VERSION_PATCH   1
 The patch version number of MPack.
 
#define MPACK_VERSION
 A number containing the version number of MPack for comparison purposes.
 
#define MPACK_VERSION_AT_LEAST(major, minor, patch)
 A macro to test for a minimum version of MPack.
 
#define MPACK_VERSION_STRING
 A string containing the MPack version.
 
#define MPACK_LIBRARY_STRING
 A string describing MPack, containing the library name, version and debug mode.
 
#define MPACK_WRITER_H   1
 
#define MPACK_READER_H   1
 
#define MPACK_EXPECT_H   1
 
#define MPACK_NODE_H   1
 
File Configuration
#define MPACK_HAS_CONFIG   0
 Causes MPack to include a file you create called mpack-config.h .
 
Features
#define MPACK_READER   1
 Enables compilation of the base Tag Reader.
 
#define MPACK_EXPECT   1
 Enables compilation of the static Expect API.
 
#define MPACK_NODE   1
 Enables compilation of the dynamic Node API.
 
#define MPACK_WRITER   1
 Enables compilation of the Writer.
 
#define MPACK_COMPATIBILITY   0
 Enables compatibility features for reading and writing older versions of MessagePack.
 
#define MPACK_EXTENSIONS   0
 Enables the use of extension types.
 
#define MPACK_BUILDER   0
 Enables compilation of the Builder.
 
Dependencies
#define MPACK_CONFORMING   1
 Enables the inclusion of basic C headers to define standard types and macros.
 
#define MPACK_STDLIB   0
 Enables the use of the C stdlib.
 
#define MPACK_STDIO   0
 Enables the use of C stdio.
 
#define MPACK_FLOAT   1
 Whether the 'float' type and floating point operations are supported.
 
#define MPACK_DOUBLE   0
 Whether the 'double' type is supported.
 
Debugging Options
#define MPACK_DEBUG   0
 Enables debug features.
 
#define MPACK_STRINGS   1
 Enables descriptive error and type strings.
 
#define MPACK_CUSTOM_ASSERT   0
 Set this to 1 to implement a custom mpack_assert_fail() function.
 
#define MPACK_READ_TRACKING   0
 Enables compound type size tracking for readers.
 
#define MPACK_WRITE_TRACKING   0
 Enables compound type size tracking for writers.
 
Miscellaneous Options
#define MPACK_OPTIMIZE_FOR_SIZE   0
 Whether to optimize for size or speed.
 
#define MPACK_STACK_SIZE   4096
 Stack space in bytes to use when initializing a reader or writer with a stack-allocated buffer.
 
#define MPACK_BUFFER_SIZE   4096
 Buffer size to use for allocated buffers (such as for a file writer.)
 
#define MPACK_PAGE_SIZE   4096
 Minimum size for paged allocations in bytes.
 
#define MPACK_NODE_PAGE_SIZE   MPACK_PAGE_SIZE
 Minimum size of an allocated node page in bytes.
 
#define MPACK_BUILDER_PAGE_SIZE   MPACK_PAGE_SIZE
 Minimum size of an allocated builder page in bytes.
 
#define MPACK_BUILDER_INTERNAL_STORAGE   0
 Enables a small amount of internal storage within the writer to avoid some allocations when using builders.
 
#define MPACK_BUILDER_INTERNAL_STORAGE_SIZE   256
 Amount of space reserved inside mpack_writer_t for the Builders.
 
#define MPACK_NODE_INITIAL_DEPTH   8
 The initial depth for the node parser.
 
#define MPACK_NODE_MAX_DEPTH_WITHOUT_MALLOC   32
 The maximum depth for the node parser if MPACK_MALLOC is not available.
 

Typedefs

typedef enum mpack_error_t mpack_error_t
 Error states for MPack objects.
 
typedef enum mpack_type_t mpack_type_t
 Defines the type of a MessagePack tag.
 
typedef struct mpack_tag_t mpack_tag_t
 An MPack tag is a MessagePack object header.
 

Enumerations

enum  mpack_error_t {
  mpack_ok = 0 , mpack_error_io = 2 , mpack_error_invalid , mpack_error_unsupported ,
  mpack_error_type , mpack_error_too_big , mpack_error_memory , mpack_error_bug ,
  mpack_error_data , mpack_error_eof
}
 Error states for MPack objects. More...
 
enum  mpack_type_t {
  mpack_type_missing = 0 , mpack_type_nil , mpack_type_bool , mpack_type_int ,
  mpack_type_uint , mpack_type_float , mpack_type_double , mpack_type_str ,
  mpack_type_bin , mpack_type_array , mpack_type_map
}
 Defines the type of a MessagePack tag. More...
 

Functions

const char * mpack_error_to_string (mpack_error_t error)
 Converts an MPack error to a string.
 
const char * mpack_type_to_string (mpack_type_t type)
 Converts an MPack type to a string.
 
Tag Querying Functions
MPACK_INLINE mpack_type_t mpack_tag_type (mpack_tag_t *tag)
 Gets the type of a tag.
 
MPACK_INLINE bool mpack_tag_bool_value (mpack_tag_t *tag)
 Gets the boolean value of a bool-type tag.
 
MPACK_INLINE int64_t mpack_tag_int_value (mpack_tag_t *tag)
 Gets the signed integer value of an int-type tag.
 
MPACK_INLINE uint64_t mpack_tag_uint_value (mpack_tag_t *tag)
 Gets the unsigned integer value of a uint-type tag.
 
MPACK_INLINE uint32_t mpack_tag_raw_float_value (mpack_tag_t *tag)
 Gets the float value of a float-type tag.
 
MPACK_INLINE uint64_t mpack_tag_raw_double_value (mpack_tag_t *tag)
 Gets the double value of a double-type tag.
 
MPACK_INLINE uint32_t mpack_tag_array_count (mpack_tag_t *tag)
 Gets the number of elements in an array tag.
 
MPACK_INLINE uint32_t mpack_tag_map_count (mpack_tag_t *tag)
 Gets the number of key-value pairs in a map tag.
 
MPACK_INLINE uint32_t mpack_tag_str_length (mpack_tag_t *tag)
 Gets the length in bytes of a str-type tag.
 
MPACK_INLINE uint32_t mpack_tag_bin_length (mpack_tag_t *tag)
 Gets the length in bytes of a bin-type tag.
 
MPACK_INLINE uint32_t mpack_tag_bytes (mpack_tag_t *tag)
 Gets the length in bytes of a str-, bin- or ext-type tag.
 
Other tag functions
int mpack_tag_cmp (mpack_tag_t left, mpack_tag_t right)
 Compares two tags with an arbitrary fixed ordering.
 
MPACK_INLINE bool mpack_tag_equal (mpack_tag_t left, mpack_tag_t right)
 Compares two tags for equality.
 
Deprecated Tag Generators
MPACK_INLINE mpack_tag_t mpack_tag_nil (void)
 
MPACK_INLINE mpack_tag_t mpack_tag_bool (bool value)
 
MPACK_INLINE mpack_tag_t mpack_tag_true (void)
 
MPACK_INLINE mpack_tag_t mpack_tag_false (void)
 
MPACK_INLINE mpack_tag_t mpack_tag_int (int64_t value)
 
MPACK_INLINE mpack_tag_t mpack_tag_uint (uint64_t value)
 
MPACK_INLINE mpack_tag_t mpack_tag_array (int32_t count)
 
MPACK_INLINE mpack_tag_t mpack_tag_map (int32_t count)
 
MPACK_INLINE mpack_tag_t mpack_tag_str (int32_t length)
 
MPACK_INLINE mpack_tag_t mpack_tag_bin (int32_t length)
 

Tag Generators

#define MPACK_TAG_ZERO   {(mpack_type_t)0, {0}}
 An mpack_tag_t initializer that zeroes the given tag.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_nil (void)
 Generates a nil tag.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_bool (bool value)
 Generates a bool tag.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_true (void)
 Generates a bool tag with value true.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_false (void)
 Generates a bool tag with value false.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_int (int64_t value)
 Generates a signed int tag.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_uint (uint64_t value)
 Generates an unsigned int tag.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_raw_float (uint32_t value)
 Generates a float tag from a raw uint32_t.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_raw_double (uint64_t value)
 Generates a double tag from a raw uint64_t.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_array (uint32_t count)
 Generates an array tag.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_map (uint32_t count)
 Generates a map tag.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_str (uint32_t length)
 Generates a str tag.
 
MPACK_INLINE mpack_tag_t mpack_tag_make_bin (uint32_t length)
 Generates a bin tag.
 

Detailed Description

Abstracts all platform-specific code from MPack and handles configuration options.

Declares the MPack dynamic Node API.

Declares the MPack static Expect API.

Declares the core MPack Tag Reader.

Declares the MPack Writer.

Defines types and functions shared by the MPack reader and writer.

This verifies the configuration and sets defaults based on the platform, contains implementations of standard C functions when libc is not available, and provides wrappers to all library functions.

Documentation for configuration options is available here:

https://ludocode.github.io/mpack/group__config.html

Macro Definition Documentation

◆ MPACK_AMALGAMATED

#define MPACK_AMALGAMATED   1

The MIT License (MIT)

Copyright (c) 2015-2021 Nicholas Fraser and the MPack authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

◆ MPACK_COMMON_H

#define MPACK_COMMON_H   1

◆ MPACK_EXPECT_H

#define MPACK_EXPECT_H   1

◆ MPACK_NODE_H

#define MPACK_NODE_H   1

◆ MPACK_PLATFORM_H

#define MPACK_PLATFORM_H   1

◆ MPACK_PRINT_BYTE_COUNT

#define MPACK_PRINT_BYTE_COUNT   12

◆ MPACK_READER_H

#define MPACK_READER_H   1

◆ MPACK_WRITER_H

#define MPACK_WRITER_H   1