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