100 while (t.
next(token))
107 std::ostringstream text;
108 text <<
"range of enumeration attribute \"" <<
p_name <<
"\" is empty";
109 throw std::runtime_error(text.str().c_str());
137 const std::string * x = &((*p_enumerators)[i]);
138 if (x->length() == length)
140 if (memcmp(s, x->data(), length) == 0)
160 const std::string * x = &((*p_enumerators)[i]);
161 if (x->length() == length)
163 if (memcmp(s, x->data(), length) == 0)
170 std::ostringstream text;
171 text <<
"value \'" << s <<
"\' is out of range \'" <<
get_range() <<
'\'';
172 throw std::runtime_error(text.str().c_str());
175 throw std::runtime_error(
"attribute is not enumeration");
181 const std::string * p_enumerators_first(&((*
p_enumerators)[0]));
182 return (d.data.ENUMERATION - p_enumerators_first);
193 d.set_init_value(a,
false);
196 catch (std::exception& ex)
198 std::ostringstream text;
199 text <<
"failed to set initial value \'" << a->
get_init_value() <<
"\' of attribute \'" << a->
get_name() <<
"\':\n" << ex.what();
200 throw std::runtime_error(text.str().c_str());
223 const std::string& r,
const std::string& init_v,
const std::string& ds,
267 s <<
"Attribute name: \"" << a.
p_name <<
"\"\n"
268 " type: \"" << a.
get_type() <<
"\"\n"
269 " range: \"" << a.
p_range <<
"\"\n";
276 s <<
" is \'multi values\'\n";
279 s <<
" is \'single value\'\n";
284 << (a.
p_no_null ==
true ?
" can not be null\n" :
" can be null\n")
285 <<
" is " << (a.
p_ordered ==
true ?
"ordered" :
"unordered") << std::endl;
296 std::ostringstream text;
297 text <<
"single-value attribute \"" <<
p_name <<
"\" is of \"class_type\" and has empty init value";
298 throw std::runtime_error(text.str().c_str());
371 throw BadFileData(std::string(
"Value \'") + attr.
value() +
"\' is not a valid attribute type", s.get_line_no(), s.get_line_pos());
386 else if (!strcmp(attr.
name(),
"multi-value-implementation"))
387 s.error_msg(
"OksAttribute::OksAttribute(OksXmlInputStream&)") <<
"Obsolete oks-attribute\'s attribute \'" << attr.
name() <<
"\'\n";
389 s.throw_unexpected_attribute(attr.
name());
396 catch (std::exception & e)
405 throw FailedRead(
"oks attribute",
BadFileData(
"attribute type is not set", s.get_line_no(), s.get_line_pos()));
414 catch (std::exception& ex)
421 if (p_data_type == OksData::class_type && p_multi_values == false)
423 std::ostringstream text;
424 text <<
"single-value attribute \"" << p_name <<
"\" is of \"class_type\" and has empty init value";
425 throw FailedRead(
"oks attribute", BadFileData(text.str(), s.get_line_no(), s.get_line_pos()));
437 _d.
SetValues(p_init_value.c_str(),
this);
441 _d.
type = p_data_type;
442 _d.
SetValue(p_init_value.c_str(), 0);
447 std::ostringstream text;
448 text <<
"attribute \"" << p_name <<
"\" has bad init value:\n" << ex.what();
458 catch (std::exception& ex)
460 std::ostringstream text;
461 text <<
"attribute \"" << p_name <<
"\" has mismatch between init value and range:\n" << ex.what();
520 static std::string __types [] = {
555 std::ostringstream text;
556 text <<
"the type \'" << t <<
"\' is not valid";
564 p_class->lock_file(
"OksAttribute::set_type");
568 if (skip_init ==
false)
575 catch (std::exception& ex)
583 p_class->registrate_attribute_change(
this);
607 catch (std::exception& ex)
614 if (
p_class->find_direct_attribute(new_name) != 0)
616 std::ostringstream text;
617 text <<
"Class \"" <<
p_class->get_name() <<
"\" already has direct attribute \"" << new_name <<
'\"';
623 p_class->lock_file(
"OksAttribute::set_name");
649 p_class->lock_file(
"OksAttribute::set_is_multi_values");
656 p_class->registrate_attribute_change(
this);
669 p_class->lock_file(
"OksAttribute::set_init_value");
694 p_class->lock_file(
"OksAttribute::set_description");
710 p_class->lock_file(
"OksAttribute::set_is_no_null");
725 p_class->lock_file(
"OksAttribute::set_format");
739 std::string old_value =
p_range;
742 p_class->lock_file(
"OksAttribute::set_range");
749 while (t.
next(token))
764 throw SetOperationFailed(
"OksAttribute::set_range",
"boolean type can't have user-defined range!");
774 catch (std::exception& ex)
809 if (token && (p = strstr(
range, token)) != 0)
811 int len = strlen(token);
815 if (((p !=
range) && (p[-1] !=
',')) || ((p[len] !=
',') && (p[len] !=
'\0')))
817 p = strstr(p + 1, token);
834 return (s.size() == 1 && s[0] ==
'*');
848 std::string token, token1, token2;
850 while (t.
next(token))
854 TLOG_DEBUG(2) <<
"token \'" << token <<
"\' of \'" <<
range <<
"\' allows any value";
859 static const char __dot_dot_str[] =
"..";
860 std::string::size_type p = token.find(__dot_dot_str, 0, (
sizeof(__dot_dot_str) - 1));
864 if (p != std::string::npos)
866 token1.assign(token, 0, p);
867 token2.assign(token, p + 2, std::string::npos);
872 token1.assign(token);
881 TLOG_DEBUG(2) <<
"token \'" << token <<
"\' of \'" <<
range <<
"\' allows any value";
896 TLOG_DEBUG(2) <<
"token \'" << token <<
"\' of \'" <<
range <<
"\' defines equality condition";
909 TLOG_DEBUG(2) <<
"token \'" << token <<
"\' of \'" <<
range <<
"\' defines smaller condition";
914 TLOG_DEBUG(2) <<
"token \'" << token <<
"\' of \'" <<
range <<
"\' defines greater condition";
919 TLOG_DEBUG(2) <<
"token \'" << token <<
"\' of \'" <<
range <<
"\' defines interval condition";
932 catch (std::exception& ex)
942 for (
const auto& x :
m_less)
962 if (d >= x.first && d <= x.second)
966 for (
const auto& x :
m_like)
971 if (boost::regex_match(d.str(),x))
OksData::Type p_data_type
static const char * uid_type
static const char * s8_int_type
void set_range(const std::string &range)
Set attribute range.
static const char * u32_int_type
static const char * u8_int_type
static const char * time_type
static const char * s64_int_type
static const char format_xml_attr[]
void set_type(const std::string &type, bool skip_init=false)
Set attribute type.
static const char description_xml_attr[]
static const char * bool_type
static const char name_xml_attr[]
void __set_data_type(const char *t, size_t len) noexcept
const std::string & get_type() const noexcept
Get attribute string type.
static const char ordered_xml_attr[]
const std::string & get_range() const noexcept
Get attribute range.
void set_is_multi_values(bool multi_values)
Set attribute is a single-value or multi-value.
void set_format(Format format)
Set attribute format.
const std::string & get_name() const noexcept
out stream operator
static const char * class_type
static const char * string_type
void save(OksXmlOutputStream &) const
static const char * enum_type
static const char * s32_int_type
static const char init_value_xml_attr[]
static bool find_token(const char *token, const char *range) noexcept
Finds token in given range.
static const char * format2str(Format) noexcept
OksAttribute(const std::string &name, OksClass *p=nullptr)
OKS attribute simple constructor.
static const char attribute_xml_tag[]
static const char * s16_int_type
static const char * u64_int_type
static const char * double_type
std::vector< std::string > * p_enumerators
bool operator==(const class OksAttribute &) const
const std::string & get_init_value() const noexcept
const std::string * get_enum_value(const char *s, size_t length) const
Returns pointer on internal enumerator data equal to given string, if such string is defined in attri...
void set_is_no_null(bool no_null)
Set attribute is-no-null property.
static const char is_multi_value_xml_attr[]
bool is_number() const noexcept
static const char * u16_int_type
int get_enum_index(const char *s, size_t length) const noexcept
Finds index of given string in attribute's range.
static const char * date_type
static const char is_not_null_xml_attr[]
static const char * float_type
static Format str2format(const char *) noexcept
void set_description(const std::string &description)
Set attribute description.
void set_init_value(const std::string &init_value)
Set attribute initialisation value.
static const char type_xml_attr[]
static const char range_xml_attr[]
bool is_integer() const noexcept
static OksData::Type get_data_type(const std::string &type) noexcept
Converts string to attribute OKS data type.
void set_name(const std::string &name)
Set attribute name.
std::string p_description
@ ChangeAttributeDescription
@ ChangeAttributeIsNoNull
@ ChangeAttributeInitValue
@ ChangeAttributeMultiValueCardinality
static bool get_skip_string_range()
Get status of string range validator.
std::list< std::pair< OksData, OksData > > m_interval
bool validate(const OksData &) const
std::list< OksData > m_less
std::list< OksData > m_great
std::list< boost::regex > m_like
std::list< OksData > m_equal
void reset(const std::string &range, OksAttribute *a)
virtual const char * what() const noexcept
#define TLOG_DEBUG(lvl,...)
const char * bool2str(bool b) noexcept
bool str2bool(const char *s) noexcept
bool cmp_str2n(const char *s1, const char s2[2])
bool cmp_str1(const char *s1, const char s2[2])
bool cmp_str4(const char *s1, const char s2[5])
bool cmp_str6(const char *s1, const char s2[7])
bool cmp_str10(const char *s1, const char s2[11])
bool cmp_str5n(const char *s1, const char s2[5])
bool cmp_str3n(const char *s1, const char s2[3])
void validate_init2range(const OksAttribute *a)
void validate_not_empty(const std::string &value, const char *name)
std::ostream & operator<<(std::ostream &s, const oks::exception &ex)
bool is_star(const std::string &s)
bool cmp_str5(const char *s1, const char s2[6])
bool cmp_str11(const char *s1, const char s2[12])
bool cmp_str3(const char *s1, const char s2[4])
bool cmp_str6n(const char *s1, const char s2[6])
bool cmp_str14(const char *s1, const char s2[14])
bool cmp_str7(const char *s1, const char s2[8])
bool cmp_str4n(const char *s1, const char s2[4])
DAC value out of range
Message.
the structure to pass common parameters to various read() methods of OksData and OksObject class
void SetValue(const char *s, const OksAttribute *a)
void SetValues(const char *, const OksAttribute *a)
enum dunedaq::oks::OksData::Type type
void ReadFrom(const char *, Type, const OksAttribute *)