Add object and array size queries to rjp++
This commit is contained in:
parent
cceb4eda7a
commit
f763438c47
@ -20,6 +20,7 @@
|
|||||||
#define RJP_ARRAY_HPP
|
#define RJP_ARRAY_HPP
|
||||||
|
|
||||||
#include <rjp.h>
|
#include <rjp.h>
|
||||||
|
#include <cstdlib> //size_t
|
||||||
#include "iterator.hpp"
|
#include "iterator.hpp"
|
||||||
#include "value.hpp"
|
#include "value.hpp"
|
||||||
#include "integral.hpp"
|
#include "integral.hpp"
|
||||||
@ -57,6 +58,7 @@ namespace rjp{
|
|||||||
public:
|
public:
|
||||||
using iterator = array_iterator;
|
using iterator = array_iterator;
|
||||||
using const_iterator = const iterator;
|
using const_iterator = const iterator;
|
||||||
|
using size_type = size_t;
|
||||||
public:
|
public:
|
||||||
using value::value;
|
using value::value;
|
||||||
array(void);
|
array(void);
|
||||||
@ -102,6 +104,8 @@ namespace rjp{
|
|||||||
const_iterator begin(void)const;
|
const_iterator begin(void)const;
|
||||||
const_iterator end(void)const;
|
const_iterator end(void)const;
|
||||||
|
|
||||||
|
size_type size(void)const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static RJP_value* create_element(RJP_value* arr);
|
static RJP_value* create_element(RJP_value* arr);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <rjp.h>
|
#include <rjp.h>
|
||||||
#include <rexy/string_base.hpp>
|
#include <rexy/string_base.hpp>
|
||||||
|
#include <cstdlib> //size_t
|
||||||
#include "value.hpp"
|
#include "value.hpp"
|
||||||
#include "iterator.hpp"
|
#include "iterator.hpp"
|
||||||
#include "member.hpp"
|
#include "member.hpp"
|
||||||
@ -60,6 +61,7 @@ namespace rjp{
|
|||||||
public:
|
public:
|
||||||
using iterator = object_iterator;
|
using iterator = object_iterator;
|
||||||
using const_iterator = const iterator;
|
using const_iterator = const iterator;
|
||||||
|
using size_type = size_t;
|
||||||
public:
|
public:
|
||||||
using value::value;
|
using value::value;
|
||||||
object(void);
|
object(void);
|
||||||
@ -134,6 +136,8 @@ namespace rjp{
|
|||||||
const_iterator begin(void)const;
|
const_iterator begin(void)const;
|
||||||
iterator end(void)const;
|
iterator end(void)const;
|
||||||
|
|
||||||
|
size_type size(void)const;
|
||||||
|
|
||||||
value search(const rexy::string_base<char>& key)const;
|
value search(const rexy::string_base<char>& key)const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -82,6 +82,9 @@ namespace rjp{
|
|||||||
array::iterator array::end(void){
|
array::iterator array::end(void){
|
||||||
return iterator();
|
return iterator();
|
||||||
}
|
}
|
||||||
|
array::size_type array::size(void)const{
|
||||||
|
return rjp_num_elements(m_value);
|
||||||
|
}
|
||||||
RJP_value* array::create_element(RJP_value* arr){
|
RJP_value* array::create_element(RJP_value* arr){
|
||||||
return rjp_new_element(arr);
|
return rjp_new_element(arr);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,6 +122,9 @@ namespace rjp{
|
|||||||
object::iterator object::end(void)const{
|
object::iterator object::end(void)const{
|
||||||
return iterator();
|
return iterator();
|
||||||
}
|
}
|
||||||
|
object::size_type object::size(void)const{
|
||||||
|
return rjp_num_members(m_value);
|
||||||
|
}
|
||||||
value object::search(const rexy::string_base<char>& key)const{
|
value object::search(const rexy::string_base<char>& key)const{
|
||||||
RJP_value* result = rjp_search_member(m_value, key.get());
|
RJP_value* result = rjp_search_member(m_value, key.get());
|
||||||
return create_unmanaged(result);
|
return create_unmanaged(result);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user