WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN > Class Template Reference

Load JSON file using jsmn utility. More...

#include <JsonCdl.hpp>

Classes

struct  _cdl_info_t
 Hold all info associated with a single CDL. More...

Public Member Functions

 JsonCdl ()
 ~JsonCdl ()
int16 registerCdl (const char *name, cdl_types_e cdl_type, uint8 cdl_size, void *data_ptr)
 Register a CDL to be loaded.
int16 parseCdlFile (const char *file_data, uint32 file_len)
 Parse a CDL file given at file_data.

Public Attributes

uint32 num_loaded_correct = 0
uint32 num_missing = 0
uint32 num_errors = 0
uint32 num_failed_registries = 0

Protected Member Functions

int16 _loadSingleCdl (const _cdl_info_t *cdl_info_ptr, const char *file_data, jsmntok_t *json_ptr, uint8 num_tok)
 Load a single CDL from the json file.

Protected Attributes

uint32 _storage_index = 0
_cdl_info_t _cdls [NUM_CDLS]
 Storage array for CDLs.

Detailed Description

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
class clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >

Load JSON file using jsmn utility.

The JsonCdl class is tasked with parsing CDLs stored in JSON format from json files stored in any location. It does not load the file, but takes a string of CDLs and 1) Loads them in 2) Counts missing CDLs 3) Counts CDLs that were loaded incorrectly

Templated parameters:

  • NUM_CDLS: The maximum number of CDLs
  • MAX_JSON_KEY_LEN: The maximum string length of a JSON key
  • MAX_JSON_FIELD_LEN: The maximum string length of a JSON field

Constructor & Destructor Documentation

◆ JsonCdl()

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::JsonCdl ( )
inline

◆ ~JsonCdl()

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::~JsonCdl ( )
inline

Member Function Documentation

◆ _loadSingleCdl()

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
int16 clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::_loadSingleCdl ( const _cdl_info_t * cdl_info_ptr,
const char * file_data,
jsmntok_t * json_ptr,
uint8 num_tok )
protected

Load a single CDL from the json file.

Parameters
cdl_info_ptrPointer to cdl info struct
file_dataThe file data loaded
tokensArray of jsmn tokens to load
num_tokensThe number of tokens to utilize
Returns
Error code corresponding to success/failure

◆ parseCdlFile()

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
int16 clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::parseCdlFile ( const char * file_data,
uint32 file_len )

Parse a CDL file given at file_data.

Parameters
file_dataThe file c string to parse. Must be valid c string
file_lenThe length of the file
Returns
Error code corresponding to success/failure

◆ registerCdl()

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
int16 clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::registerCdl ( const char * name,
cdl_types_e cdl_type,
uint8 cdl_size,
void * data_ptr )

Register a CDL to be loaded.

Parameters
nameName of the CDL. Must be a valid C string
cdl_typeThe CDL type
sizeThe length of the CDL type, in number of values (NOT bytes)
data_ptrPointer to location at which CDL should be saved
Returns
Error code corresponding to success/failure

Member Data Documentation

◆ _cdls

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
_cdl_info_t clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::_cdls[NUM_CDLS]
protected

Storage array for CDLs.

◆ _storage_index

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
uint32 clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::_storage_index = 0
protected

◆ num_errors

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
uint32 clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::num_errors = 0

◆ num_failed_registries

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
uint32 clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::num_failed_registries = 0

◆ num_loaded_correct

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
uint32 clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::num_loaded_correct = 0

◆ num_missing

template<uint32 NUM_CDLS, uint32 MAX_JSON_KEY_LEN, uint32 MAX_JSON_FIELD_LEN>
uint32 clockwerk::JsonCdl< NUM_CDLS, MAX_JSON_KEY_LEN, MAX_JSON_FIELD_LEN >::num_missing = 0

The documentation for this class was generated from the following file:
  • /Users/mickey/Documents/Projects/warptwin/warpos/clockwerk/src/logging/JsonCdl.hpp