Utilities

Zero-dependency JSON DOM (JSONObject, JSONArray, JSONVariant), tabular Cursor, indexed Map<T,Q>, String, and tagged Variant.

class JSONObject JBit::Utils · Utils/JSON/JSONObject.hpp · 4 members

DOM JSON object parser/serializer used by tokenizer.json, model configs, and JBitServer.

inherits AbstractJSONObject
static AbstractJSONObject *createFromData(const std::string &data) / createFromFile(const char *filename);
void putString/putInt/putDouble/putBool/putNull(const std::string &key, ...);
std::string getString/int getInt/double getDouble/bool getBool/JSONObject* getJSONObject/JSONArray* getJSONArray(const std::string &key);
std::string toString() override / std::string toFormattedString(...) override / void formattedExportToFile(const char *filename);
class JSONArray JBit::Utils · Utils/JSON/JSONArray.hpp · 2 members

DOM JSON array container.

inherits AbstractJSONObject
void putString/putInt/putDouble/putBool(...) & getString/getInt/getJSONObject/getJSONArray(unsigned long long index);
unsigned long long size() const;
class Cursor JBit::Utils · Utils/Cursor/Cursor.hpp · 2 members

In-memory tabular row cursor with typed column getters.

int addRow() / void put(const std::string &key, const Variant &value) / bool next() / bool prev();
int getInt/double getDouble/bool getBool/std::string getStdString(const std::string &key) const;
class Map JBit::Utils · Utils/Map/Map.hpp · 1 member
template<typename T, typename Q>

Associative container supporting both key lookup and O(1)-cached positional index access.

void put(const T &k, const Q &v) / Q &get(const T &k) / Q &get(size_type index) / bool contains(const T &k) const;
class String JBit::Utils · Utils/String/String.hpp · 2 members

Drop-in std::string subclass with split, join, trim, replace, and case utilities.

inherits std::string
std::vector<String> split(const std::string &delimiter) const / static String join(const std::vector<String> &parts, const std::string &delimiter);
String trim() const / toLowerCase() const / toUpperCase() const / replace(const String &search, const String &replaceWith) const;
class Variant JBit::Utils · Utils/Variant/Variant.hpp · 1 member

Compact tagged scalar/string union.

bool isBoolType() const / isNumericType() const / isStringType() const / int toInt() const / double toDouble() const / std::string toStdString() const;