9 #ifndef __NODAMUSHI_SVD_VALUE_HPP__ 10 #define __NODAMUSHI_SVD_VALUE_HPP__ 13 # include <type_traits> 14 # include <functional> 53 template<
typename T,
bool attribute,
bool required,
char... name>
struct value 64 value():_value(),_has_value(false){};
84 template<typename SVD> auto operator =(SVD& src)
99 ->typename std::enable_if<std::is_base_of<svd_reader,SVD>::value
114 ->typename std::enable_if<!std::is_base_of<svd_reader,V>::value
117 _value =
value; _has_value =
true;
127 _value = std::move(
value); _has_value =
true;
134 void clear()noexcept;
189 bool operator==(
const type& t)
const noexcept{
return _has_value? _value ==t:
false;}
196 bool operator!=(
const type& t)
const noexcept{
return _has_value? _value !=t:
true;}
220 {
return _has_value&&t._has_value? _value ==t._value:_has_value==t._has_value;}
230 {
return _has_value&&t._has_value? _value !=t._value:_has_value!=t._has_value;}
243 type&
get(
type& defaultValue)noexcept{
return _has_value?_value:defaultValue;}
249 type&
get(
type&& defaultValue)noexcept{
return _has_value?_value:defaultValue;}
255 const type&
get(
const type& defaultValue)
const noexcept{
return _has_value?_value:defaultValue;}
263 bool empty()const noexcept{
return !_has_value;}
268 operator bool()const noexcept{
return _has_value;}
285 # ifndef __DOXYGEN__DOCUMENT__PREPROCESSOR__ 287 # define SVD_VALUE(type,name,...) \ 288 _SVD_VALUE_(type,name,false,__VA_ARGS__,_SVD_VALUE0_,_SVD_VALUE1_,0) 290 # define SVD_ATTR(type,name,...) \ 291 _SVD_VALUE_(type,name,true,__VA_ARGS__,_SVD_VALUE0_,_SVD_VALUE1_,0) 293 # define SVD_TYPE(type,attr,require,name) \ 294 value_t<type,attr,require,__SVD_VALUE_EXPAND_NAME__(name)> 303 # define SVD_VALUE(type,name,...) \ 304 value<type,ELEMENT> name 306 # define SVD_ATTR(type,name,...) \ 307 value<type,ATTR> name 309 # define SVD_TYPE(type,attr,require,name) \ 315 #endif // __NODAMUSHI_SVD_VALUE_HPP__ value(const type &t)
constructor with initial value
bool empty() const noexcept
when this object is empty,return true.
value()
default constructor
type & get(type &&defaultValue) noexcept
get or else
const type & get(const type &defaultValue) const noexcept
get or else
constexpr bool is_required() const noexcept
bool operator!=(const value &&t) const noexcept
value != t
type & get_for_init() noexcept
Get value to initialize. After this method is called, empty() method returns false.
constexpr bool is_attribute() const noexcept
bool check_require() const noexcept
Check not empty if this element/attribute is required.
const type * operator->() const
->
auto operator=(SVD &src) -> typename std::enable_if< std::is_base_of< svd_reader, SVD >::value, bool >::type
set value from SVD reader
typename value_type_t::type type
bool operator==(const type &t) const noexcept
value == t
bool value_try_set(DST &dst, SVD &src)
bool operator==(const value &t) const noexcept
value == t
bool operator!=(type &&t) const noexcept
value != t
This class reperesents SVD(xml) element / attribute.
static constexpr bool ATTRIBUTE
type & get(type &defaultValue) noexcept
get or else
std::string get_name() const noexcept
#define NODAMUSHI_CONSTEXPR_STRING
bool operator==(type &&t) const noexcept
value == t
type & operator *()
get value
void clear() noexcept
clear this object. After calling this method,this object status will be empty.
empty_value_access_error(std::string &message)
access to the empty value object.
static constexpr bool REQUIRED
bool operator!=(const type &t) const noexcept
value != t
const type & get() const
get value