98 lines
2.6 KiB
C++
98 lines
2.6 KiB
C++
/**
|
|
This file is a part of rexy's matrix client
|
|
Copyright (C) 2019 rexy712
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef RJP_ITERATOR_HPP
|
|
#define RJP_ITERATOR_HPP
|
|
|
|
#include <rjp.h>
|
|
|
|
namespace raii{
|
|
|
|
class rjp_object_iterator
|
|
{
|
|
public:
|
|
using iterator = RJP_value*;
|
|
using const_iterator = const iterator;
|
|
private:
|
|
RJP_value* m_value;
|
|
public:
|
|
constexpr rjp_object_iterator(RJP_value* v):m_value(v){}
|
|
constexpr rjp_object_iterator(const rjp_object_iterator& e):m_value(e.m_value){}
|
|
constexpr rjp_object_iterator& operator=(const rjp_object_iterator& e){
|
|
m_value = e.m_value;
|
|
return *this;
|
|
}
|
|
constexpr bool operator==(const rjp_object_iterator& e)const{
|
|
return m_value == e.m_value;
|
|
}
|
|
constexpr bool operator!=(const rjp_object_iterator& e)const{
|
|
return m_value != e.m_value;
|
|
}
|
|
rjp_object_iterator& operator++(void);
|
|
constexpr RJP_value* operator*(void){
|
|
return m_value;
|
|
}
|
|
constexpr const RJP_value* operator*(void)const{
|
|
return m_value;
|
|
}
|
|
constexpr RJP_value& operator->(void){
|
|
return *m_value;
|
|
}
|
|
constexpr const RJP_value& operator->(void)const{
|
|
return *m_value;
|
|
}
|
|
};
|
|
class rjp_array_iterator
|
|
{
|
|
public:
|
|
using iterator = RJP_value*;
|
|
using const_iterator = const iterator;
|
|
private:
|
|
RJP_value* m_value;
|
|
public:
|
|
constexpr rjp_array_iterator(RJP_value* v):m_value(v){}
|
|
constexpr rjp_array_iterator(const rjp_array_iterator& e):m_value(e.m_value){}
|
|
constexpr rjp_array_iterator& operator=(const rjp_array_iterator& e){
|
|
m_value = e.m_value;
|
|
return *this;
|
|
}
|
|
constexpr bool operator==(const rjp_array_iterator& e)const{
|
|
return m_value == e.m_value;
|
|
}
|
|
constexpr bool operator!=(const rjp_array_iterator& e)const{
|
|
return m_value != e.m_value;
|
|
}
|
|
rjp_array_iterator& operator++(void);
|
|
constexpr RJP_value* operator*(void){
|
|
return m_value;
|
|
}
|
|
constexpr const RJP_value* operator*(void)const{
|
|
return m_value;
|
|
}
|
|
constexpr RJP_value& operator->(void){
|
|
return *m_value;
|
|
}
|
|
constexpr const RJP_value& operator->(void)const{
|
|
return *m_value;
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|