lgraph_utils

Typedefs

using json = nlohmann::json
namespace lgraph_api

Functions

double get_time()

Get current time.

Returns

Digit value of current time.

void split_string(std::string origin_string, std::vector<std::string> &sub_strings, std::string string_delimiter)

Split the original string by format.

Parameters
  • origin_string – original string to be split.

  • sub_strings – split substring.

  • string_delimiter – Split format.

std::string rc4(std::string &input, std::string key, std::string mode)

Encrypt the input string in ac4 format.

Parameters
  • input – input string.

  • key – encryption key.

  • mode – encryption mode

Returns

Encrypted string

std::string encode_base64(const std::string input)

Encode the input string in encode_base64 format.

Parameters

input – input string.

Returns

Encrypted string

std::string decode_base64(const std::string input)

Decode the input string in decode_base64 format.

Parameters

input – input string.

Returns

Decrypted string.

void *alloc_buffer(size_t bytes)

Allocate memory with size in byte.

Parameters

bytes – Size in byte of request memory.

Returns

Pointer of allocated memory.

void dealloc_buffer(void *buffer, size_t bytes)

Free memory with size in byte.

Parameters
  • buffer – Size in bytes of request memory

  • bytes – Pointer of memory to free.

template<class DataType>
void parse_from_json(DataType &value, const char *key, json &input)

Parse parameter from nlohmann::json.

Parameters
  • value[out] value to store parameter

  • key – key of the parameter in the input

  • input – input json

template<class DataType>
void parse_from_json(std::vector<DataType> &value, const char *key, json &input)

Parse vector parameter from nlohmann::json.

Parameters
  • value[out] value to store parameter

  • key – key of the parameter in the input

  • input – input json