Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/core/config/descriptor_providers/json_descriptor_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ json_descriptor_provider::json_descriptor_provider(const char *json_string)

config_descriptor json_descriptor_provider::load_descriptors()
{
json_object_handle schema_handle(json_tokener_parse(m_json_string));
json_object_handle schema_handle(doca_third_party_json_tokener_parse(m_json_string));
if (!schema_handle.get()) {
throw_xlio_exception("Failed to parse JSON schema.");
}
Expand All @@ -49,7 +49,7 @@ config_descriptor json_descriptor_provider::load_descriptors()
json_object *properties =
json_utils::get_field(schema_handle.get(), config_strings::schema::JSON_PROPERTIES);

json_object_object_foreach(properties, key, val)
doca_third_party_json_object_object_foreach(properties, key, val)
{
process_schema_property(val, key, result_desc);
}
Expand All @@ -59,22 +59,22 @@ config_descriptor json_descriptor_provider::load_descriptors()

void json_descriptor_provider::validate_schema(json_object *schema)
{
if (json_object_get_type(schema) != json_type_object) {
if (doca_third_party_json_object_get_type(schema) != json_type_object) {
throw_xlio_exception("Schema root must be an object.");
}

json_object *properties =
json_utils::get_field(schema, config_strings::schema::JSON_PROPERTIES);

json_object_object_foreach(properties, key, val)
doca_third_party_json_object_object_foreach(properties, key, val)
{
if (json_object_get_type(val) != json_type_object) {
if (doca_third_party_json_object_get_type(val) != json_type_object) {
throw_xlio_exception("Property '" + std::string(key) + "' must be an object.");
}
}

json_object *type_field = json_utils::get_field(schema, config_strings::schema::JSON_TYPE);
if (std::string(json_object_get_string(type_field)) !=
if (std::string(doca_third_party_json_object_get_string(type_field)) !=
config_strings::schema_types::JSON_TYPE_OBJECT) {
throw_xlio_exception("Schema root must have type 'object'.");
}
Expand All @@ -84,15 +84,15 @@ void json_descriptor_provider::validate_terminal_property(json_object *property_
const std::string &current_path)
{
// Basic validation for terminal properties
if (!property_obj || json_object_get_type(property_obj) != json_type_object) {
if (!property_obj || doca_third_party_json_object_get_type(property_obj) != json_type_object) {
throw_xlio_exception("Invalid property object for: " + current_path);
}

// Check for required description field
json_object *description_field =
json_utils::get_field(property_obj, config_strings::schema::JSON_DESCRIPTION);

if (json_object_get_type(description_field) != json_type_string) {
if (doca_third_party_json_object_get_type(description_field) != json_type_string) {
throw_xlio_exception("Invalid 'description' field type for terminal property: " +
current_path);
}
Expand All @@ -119,8 +119,9 @@ void json_descriptor_provider::process_schema_property(json_object *property_obj
if (analysis.json_property_type == property_type::OBJECT) {
json_object *properties =
json_utils::try_get_field(property_obj, config_strings::schema::JSON_PROPERTIES);
if (properties && json_object_get_type(properties) == json_type_object) {
json_object_object_foreach(properties, key, val)
if (properties &&
doca_third_party_json_object_get_type(properties) == json_type_object) {
doca_third_party_json_object_object_foreach(properties, key, val)
{
process_schema_property(val, key, desc, current_path);
}
Expand Down
46 changes: 23 additions & 23 deletions src/core/config/descriptor_providers/schema_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
static void for_each_oneof_option(json_object *one_of_field,
std::function<void(json_object *)> func)
{
int one_of_length = json_object_array_length(one_of_field);
int one_of_length = doca_third_party_json_object_array_length(one_of_field);
for (int i = 0; i < one_of_length; i++) {
json_object *option = json_object_array_get_idx(one_of_field, i);
json_object *option = doca_third_party_json_object_array_get_idx(one_of_field, i);
func(option);
}
}
Expand Down Expand Up @@ -47,7 +47,7 @@ bool schema_analyzer::is_applicable(json_object *property_obj)
return false;
}

if (json_object_get_type(property_obj) != json_type_object) {
if (doca_third_party_json_object_get_type(property_obj) != json_type_object) {
return false;
}

Expand Down Expand Up @@ -83,15 +83,15 @@ property_type schema_analyzer::determine_property_type()
json_object *type_field =
json_utils::get_field(m_property_obj, config_strings::schema::JSON_TYPE);
std::string json_type_str;
if (json_object_get_type(type_field) == json_type_string) {
json_type_str = json_object_get_string(type_field);
if (doca_third_party_json_object_get_type(type_field) == json_type_string) {
json_type_str = doca_third_party_json_object_get_string(type_field);
}

// Object properties with nested properties
if (json_type_str == config_strings::schema_types::JSON_TYPE_OBJECT) {
json_object *properties_field =
json_utils::get_field(m_property_obj, config_strings::schema::JSON_PROPERTIES);
if (json_object_get_type(properties_field) == json_type_object) {
if (doca_third_party_json_object_get_type(properties_field) == json_type_object) {
return property_type::OBJECT;
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ std::type_index schema_analyzer::determine_value_type()
json_object *type_field =
json_utils::get_field(m_property_obj, config_strings::schema::JSON_TYPE);

std::string type_str = json_object_get_string(type_field);
std::string type_str = doca_third_party_json_object_get_string(type_field);
if (type_str == config_strings::schema_types::JSON_TYPE_BOOLEAN) {
return typeid(bool);
} else if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
Expand All @@ -151,7 +151,7 @@ std::experimental::optional<std::experimental::any> schema_analyzer::determine_d
// Check for oneOf first - default values are nested inside oneOf options
json_object *one_of_field =
json_utils::try_get_field(m_property_obj, config_strings::schema::JSON_ONE_OF);
if (one_of_field && json_object_get_type(one_of_field) == json_type_array) {
if (one_of_field && doca_third_party_json_object_get_type(one_of_field) == json_type_array) {
return extract_oneof_value(one_of_field, type, config_strings::schema::JSON_DEFAULT);
}

Expand Down Expand Up @@ -205,17 +205,17 @@ static void extract_constraints_from_json(json_object *obj, constraint_config &c
return;
}
json_object *min_field = json_utils::try_get_field(obj, config_strings::schema::JSON_MINIMUM);
if (min_field && json_object_get_type(min_field) == json_type_int) {
if (min_field && doca_third_party_json_object_get_type(min_field) == json_type_int) {
config.has_minimum = true;
config.minimum_value = json_object_get_int64(min_field);
config.minimum_value = doca_third_party_json_object_get_int64(min_field);
}
json_object *max_field = json_utils::try_get_field(obj, config_strings::schema::JSON_MAXIMUM);
if (max_field && json_object_get_type(max_field) == json_type_int) {
if (max_field && doca_third_party_json_object_get_type(max_field) == json_type_int) {
config.has_maximum = true;
config.maximum_value = json_object_get_int64(max_field);
config.maximum_value = doca_third_party_json_object_get_int64(max_field);
}
json_object *enum_field = json_utils::try_get_field(obj, config_strings::schema::JSON_ENUM);
if (enum_field && json_object_get_type(enum_field) == json_type_array) {
if (enum_field && doca_third_party_json_object_get_type(enum_field) == json_type_array) {
config.has_enum = true;
config.enum_int_values = json_utils::extract_enum_values<int64_t>(enum_field);
}
Expand All @@ -238,7 +238,7 @@ constraint_config schema_analyzer::analyze_constraint_config()
for_each_oneof_option(one_of_field, [&](json_object *option) {
json_object *type_field =
json_utils::get_field(option, config_strings::schema::JSON_TYPE);
std::string type_str = json_object_get_string(type_field);
std::string type_str = doca_third_party_json_object_get_string(type_field);
if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
extract_constraints_from_json(option, config);
}
Expand Down Expand Up @@ -269,7 +269,7 @@ enum_mapping_config_t schema_analyzer::analyze_enum_mapping_config()
for_each_oneof_option(one_of_field, [&](json_object *option) {
json_object *type_field = json_utils::get_field(option, config_strings::schema::JSON_TYPE);

std::string type_str = json_object_get_string(type_field);
std::string type_str = doca_third_party_json_object_get_string(type_field);
if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
int_option = option;
} else if (type_str == config_strings::schema_types::JSON_TYPE_STRING) {
Expand Down Expand Up @@ -315,8 +315,8 @@ bool schema_analyzer::has_memory_size_flag()
return false;
}

return json_object_get_type(memory_size_flag) == json_type_boolean &&
json_object_get_boolean(memory_size_flag);
return doca_third_party_json_object_get_type(memory_size_flag) == json_type_boolean &&
doca_third_party_json_object_get_boolean(memory_size_flag);
}

bool schema_analyzer::has_power_of_2_or_zero_flag()
Expand Down Expand Up @@ -348,13 +348,13 @@ bool schema_analyzer::has_constraint_fields()
if (has_oneof_field()) {
json_object *one_of_field =
json_utils::get_field(m_property_obj, config_strings::schema::JSON_ONE_OF);
int one_of_length = json_object_array_length(one_of_field);
int one_of_length = doca_third_party_json_object_array_length(one_of_field);
for (int i = 0; i < one_of_length; i++) {
json_object *option = json_object_array_get_idx(one_of_field, i);
json_object *option = doca_third_party_json_object_array_get_idx(one_of_field, i);
json_object *type_field =
json_utils::get_field(option, config_strings::schema::JSON_TYPE);

std::string type_str = json_object_get_string(type_field);
std::string type_str = doca_third_party_json_object_get_string(type_field);

// For integer option, check if it has constraints
if (type_str == config_strings::schema_types::JSON_TYPE_INTEGER) {
Expand All @@ -378,7 +378,7 @@ bool schema_analyzer::has_oneof_field()
json_object *one_of_field =
json_utils::try_get_field(m_property_obj, config_strings::schema::JSON_ONE_OF);

if (one_of_field && json_object_get_type(one_of_field) != json_type_array) {
if (one_of_field && doca_third_party_json_object_get_type(one_of_field) != json_type_array) {
throw_xlio_exception("OneOf field must be an array for: " + m_path);
}

Expand All @@ -389,9 +389,9 @@ std::experimental::any schema_analyzer::extract_oneof_value(json_object *one_of_
std::type_index type,
const std::string &key)
{
int one_of_length = json_object_array_length(one_of_field);
int one_of_length = doca_third_party_json_object_array_length(one_of_field);
for (int i = 0; i < one_of_length; i++) {
json_object *option = json_object_array_get_idx(one_of_field, i);
json_object *option = doca_third_party_json_object_array_get_idx(one_of_field, i);
json_object *key_field = json_utils::try_get_field(option, key.c_str());

if (key_field && std::type_index(json_utils::to_any_value(key_field).type()) == type) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/config/json_object_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ json_object_handle::json_object_handle(json_object *obj)
json_object_handle::~json_object_handle()
{
if (m_obj) {
json_object_put(m_obj);
doca_third_party_json_object_put(m_obj);
}
}

Expand Down
34 changes: 17 additions & 17 deletions src/core/config/json_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ json_object *try_get_field(json_object *obj, const char *field_name)
}

json_object *field = nullptr;
if (json_object_object_get_ex(obj, field_name, &field)) {
if (doca_third_party_json_object_object_get_ex(obj, field_name, &field)) {
return field;
}

Expand All @@ -55,7 +55,7 @@ std::experimental::any to_any_value(json_object *obj)
{json_type_object, convert_object},
{json_type_array, convert_array}};

const json_type type = json_object_get_type(obj);
const json_type type = doca_third_party_json_object_get_type(obj);
const auto converter = type_converters.find(type);

if (converter == type_converters.end()) {
Expand Down Expand Up @@ -94,7 +94,7 @@ void validate_type(json_object *obj, json_type expected_type, const std::string
throw_xlio_exception("JSON object is null in context: " + context);
}

json_type actual_type = json_object_get_type(obj);
json_type actual_type = doca_third_party_json_object_get_type(obj);
if (actual_type != expected_type) {
throw_xlio_exception("Type mismatch in " + context + ": expected " +
get_type_name(expected_type) + ", got " + get_type_name(actual_type));
Expand All @@ -104,24 +104,24 @@ void validate_type(json_object *obj, json_type expected_type, const std::string
// Converter function implementations
static std::experimental::any convert_boolean(json_object *obj)
{
return bool(json_object_get_boolean(obj));
return bool(doca_third_party_json_object_get_boolean(obj));
}

static std::experimental::any convert_integer(json_object *obj)
{
return json_object_get_int64(obj);
return doca_third_party_json_object_get_int64(obj);
}

static std::experimental::any convert_string(json_object *obj)
{
const char *s = json_object_get_string(obj);
const char *s = doca_third_party_json_object_get_string(obj);
return std::string(s ? s : config_strings::misc::EMPTY_STRING);
}

static std::experimental::any convert_object(json_object *obj)
{
std::map<std::string, std::experimental::any> obj_map;
json_object_object_foreach(obj, key, val)
doca_third_party_json_object_object_foreach(obj, key, val)
{
obj_map[key] = to_any_value(val);
}
Expand All @@ -131,11 +131,11 @@ static std::experimental::any convert_object(json_object *obj)
static std::experimental::any convert_array(json_object *obj)
{
std::vector<std::experimental::any> array_values;
const int array_length = json_object_array_length(obj);
const int array_length = doca_third_party_json_object_array_length(obj);
array_values.reserve(array_length); // Optimize memory allocation

for (int i = 0; i < array_length; i++) {
json_object *item = json_object_array_get_idx(obj, i);
json_object *item = doca_third_party_json_object_array_get_idx(obj, i);
array_values.push_back(to_any_value(item));
}
return array_values;
Expand All @@ -149,13 +149,13 @@ template <> std::vector<int64_t> extract_enum_values<int64_t>(json_object *enum_
return values;
}

const int enum_length = json_object_array_length(enum_field);
const int enum_length = doca_third_party_json_object_array_length(enum_field);
values.reserve(enum_length); // Optimize memory allocation

for (int i = 0; i < enum_length; i++) {
json_object *enum_value = json_object_array_get_idx(enum_field, i);
if (enum_value && json_object_get_type(enum_value) == json_type_int) {
values.push_back(json_object_get_int64(enum_value));
json_object *enum_value = doca_third_party_json_object_array_get_idx(enum_field, i);
if (enum_value && doca_third_party_json_object_get_type(enum_value) == json_type_int) {
values.push_back(doca_third_party_json_object_get_int64(enum_value));
}
}
return values;
Expand All @@ -168,13 +168,13 @@ template <> std::vector<std::string> extract_enum_values<std::string>(json_objec
return values;
}

const int enum_length = json_object_array_length(enum_field);
const int enum_length = doca_third_party_json_object_array_length(enum_field);
values.reserve(enum_length); // Optimize memory allocation

for (int i = 0; i < enum_length; i++) {
json_object *enum_value = json_object_array_get_idx(enum_field, i);
if (enum_value && json_object_get_type(enum_value) == json_type_string) {
const char *str_val = json_object_get_string(enum_value);
json_object *enum_value = doca_third_party_json_object_array_get_idx(enum_field, i);
if (enum_value && doca_third_party_json_object_get_type(enum_value) == json_type_string) {
const char *str_val = doca_third_party_json_object_get_string(enum_value);
if (str_val) {
values.emplace_back(str_val);
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/config/loaders/json_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ std::map<std::string, std::experimental::any> json_loader::load_all() &
return m_data;
}

json_object *raw_obj = json_object_from_file(m_source.c_str());
json_object *raw_obj = doca_third_party_json_object_from_file(m_source.c_str());
if (!raw_obj) {
throw_xlio_exception("Failed to parse JSON file: " + m_source);
}

json_object_handle root_obj(raw_obj);

if (json_object_get_type(root_obj.get()) != json_type_object) {
if (doca_third_party_json_object_get_type(root_obj.get()) != json_type_object) {
throw_xlio_exception("Top-level JSON is not an object: " + m_source);
}

Expand All @@ -43,7 +43,7 @@ std::map<std::string, std::experimental::any> json_loader::load_all() &

void json_loader::process_json_object(const std::string &prefix, json_object *obj)
{
json_object_object_foreach(obj, key, value)
doca_third_party_json_object_object_foreach(obj, key, value)
{
std::string key_str(key);
if (key_str.find('.') != std::string::npos) {
Expand All @@ -53,7 +53,7 @@ void json_loader::process_json_object(const std::string &prefix, json_object *ob
std::string current_key =
prefix.empty() ? std::move(key_str) : (prefix + config_strings::misc::DOT + key_str);

json_type type = json_object_get_type(value);
json_type type = doca_third_party_json_object_get_type(value);
if (type == json_type_object) {
// Recursively process nested objects
process_json_object(current_key, value);
Expand Down
Loading