Fix c++ compatability and const correctness
This commit is contained in:
parent
08b05e8162
commit
250c6b1e59
@ -42,7 +42,7 @@ extern "C"{
|
||||
#define RJP_float double
|
||||
#endif
|
||||
#ifndef RJP_bool
|
||||
#define RJP_bool _Bool
|
||||
#define RJP_bool char
|
||||
#endif
|
||||
|
||||
//used with rjp_to_json
|
||||
@ -172,9 +172,9 @@ RJP_value* rjp_search_member(const RJP_value* object, const char* search);
|
||||
//Access first member of a json object
|
||||
void rjp_init_object_iterator(RJP_object_iterator* iter, const RJP_value* object);
|
||||
void rjp_delete_object_iterator(RJP_object_iterator* it);
|
||||
RJP_value* rjp_object_iterator_current(RJP_object_iterator* it);
|
||||
RJP_value* rjp_object_iterator_current(const RJP_object_iterator* it);
|
||||
RJP_value* rjp_object_iterator_next(RJP_object_iterator* it);
|
||||
RJP_value* rjp_object_iterator_peek(RJP_object_iterator* it);
|
||||
RJP_value* rjp_object_iterator_peek(const RJP_object_iterator* it);
|
||||
|
||||
/***************** ARRAY OPERATIONS *******************/
|
||||
//add an element to a json array
|
||||
@ -187,9 +187,9 @@ RJP_index rjp_num_elements(const RJP_value* arr);
|
||||
/***************** ARRAY ITERATOR OPERATIONS *******************/
|
||||
void rjp_init_array_iterator(RJP_array_iterator* iter, const RJP_value* array);
|
||||
void rjp_delete_array_iterator(RJP_array_iterator* iter);
|
||||
RJP_value* rjp_array_iterator_current(RJP_array_iterator* it);
|
||||
RJP_value* rjp_array_iterator_current(const RJP_array_iterator* it);
|
||||
RJP_value* rjp_array_iterator_next(RJP_array_iterator* it);
|
||||
RJP_value* rjp_array_iterator_peek(RJP_array_iterator* it);
|
||||
RJP_value* rjp_array_iterator_peek(const RJP_array_iterator* it);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -76,12 +76,11 @@ void rjp_init_array_iterator(RJP_array_iterator* iter, const RJP_value* array){
|
||||
iter->current = &(array->array.elements->value);
|
||||
}
|
||||
void rjp_delete_array_iterator(RJP_array_iterator* it){
|
||||
if(!it)
|
||||
return;
|
||||
it->current = NULL;
|
||||
}
|
||||
RJP_value* rjp_get_element(const RJP_value* array){
|
||||
return &array->array.elements->value;
|
||||
}
|
||||
RJP_value* rjp_array_iterator_current(RJP_array_iterator* it){
|
||||
RJP_value* rjp_array_iterator_current(const RJP_array_iterator* it){
|
||||
return it->current;
|
||||
}
|
||||
RJP_value* rjp_array_iterator_next(RJP_array_iterator* it){
|
||||
@ -89,7 +88,7 @@ RJP_value* rjp_array_iterator_next(RJP_array_iterator* it){
|
||||
it->current = curr ? &(curr->next->value) : NULL;
|
||||
return it->current;
|
||||
}
|
||||
RJP_value* rjp_array_iterator_peek(RJP_array_iterator* it){
|
||||
RJP_value* rjp_array_iterator_peek(const RJP_array_iterator* it){
|
||||
RJP_array_element* curr = (RJP_array_element*)it->current;
|
||||
return curr ? &(curr->next->value) : NULL;
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ void rjp_delete_object_iterator(RJP_object_iterator* it){
|
||||
rjp_free(it->it);
|
||||
it->it = NULL;
|
||||
}
|
||||
RJP_value* rjp_object_iterator_current(RJP_object_iterator* it){
|
||||
RJP_value* rjp_object_iterator_current(const RJP_object_iterator* it){
|
||||
RJP_tree_node* n = irjp_object_iterator_current(it->it);
|
||||
if(!n)
|
||||
return NULL;
|
||||
@ -227,7 +227,7 @@ RJP_value* rjp_object_iterator_next(RJP_object_iterator* it){
|
||||
return NULL;
|
||||
return &n->data.value;
|
||||
}
|
||||
RJP_value* rjp_object_iterator_peek(RJP_object_iterator* it){
|
||||
RJP_value* rjp_object_iterator_peek(const RJP_object_iterator* it){
|
||||
RJP_tree_node* n = irjp_object_iterator_peek(it->it);
|
||||
if(!n)
|
||||
return NULL;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user