DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
attribute.cpp
Go to the documentation of this file.
1// DUNE DAQ modification notice:
2// This file has been modified from the original ATLAS oks source for the DUNE DAQ project.
3// Fork baseline commit: oks-08-03-04 (2022-04-14).
4// Renamed since fork: no.
5
6#define _OksBuildDll_
7
8#include "oks/attribute.hpp"
9#include "oks/class.hpp"
10#include "oks/cstring.hpp"
11#include "oks/kernel.hpp"
12#include "oks/object.hpp"
13#include "oks/xml.hpp"
14
15#include "logging/Logging.hpp"
16
17#include <sstream>
18#include <stdexcept>
19
20#include <string.h>
21
22namespace dunedaq {
23namespace oks {
24
25const char* OksAttribute::bool_type = "bool";
26const char* OksAttribute::s8_int_type = "s8";
27const char* OksAttribute::u8_int_type = "u8";
28const char* OksAttribute::s16_int_type = "s16";
29const char* OksAttribute::u16_int_type = "u16";
30const char* OksAttribute::s32_int_type = "s32";
31const char* OksAttribute::u32_int_type = "u32";
32const char* OksAttribute::s64_int_type = "s64";
33const char* OksAttribute::u64_int_type = "u64";
34const char* OksAttribute::float_type = "float";
35const char* OksAttribute::double_type = "double";
36const char* OksAttribute::date_type = "date";
37const char* OksAttribute::time_type = "time";
38const char* OksAttribute::string_type = "string";
39const char* OksAttribute::uid_type = "uid";
40const char* OksAttribute::enum_type = "enum";
41const char* OksAttribute::class_type = "class";
42
43const char OksAttribute::attribute_xml_tag[] = "attribute";
44const char OksAttribute::name_xml_attr[] = "name";
45const char OksAttribute::description_xml_attr[] = "description";
46const char OksAttribute::type_xml_attr[] = "type";
47const char OksAttribute::range_xml_attr[] = "range";
48const char OksAttribute::format_xml_attr[] = "format";
49const char OksAttribute::is_multi_value_xml_attr[] = "is-multi-value";
50const char OksAttribute::init_value_xml_attr[] = "init-value";
51const char OksAttribute::is_not_null_xml_attr[] = "is-not-null";
52const char OksAttribute::ordered_xml_attr[] = "ordered";
53
55OksAttribute::str2format(const char* s) noexcept
56{
57 return (cmp_str3(s, "dec") ? Dec : cmp_str3(s, "hex") ? Hex : Oct);
58}
59
60const char*
62{
63 return (f == Dec ? "dec" : f == Hex ? "hex" : "oct");
64}
65
66bool
71
72bool
77
78void
80{
82 if (p_enumerators) {
83 p_enumerators->clear();
84 } else {
85 p_enumerators = new std::vector<std::string>();
86 }
87
88 Oks::Tokenizer t(p_range, ",");
89 std::string token;
90
91 while (t.next(token)) {
92 p_enumerators->push_back(token);
93 }
94
95 if (p_enumerators->empty()) {
96 std::ostringstream text;
97 text << "range of enumeration attribute \"" << p_name << "\" is empty";
98 throw std::runtime_error(text.str().c_str());
99 }
100 }
101}
102
103void
105{
106 clean_range();
107
108 if (p_range.empty() == false) {
109 p_range_obj = new OksRange(p_range, this);
110 if (p_range_obj->is_empty()) {
111 clean_range();
112 }
113 }
114}
115
116int
117OksAttribute::get_enum_index(const char* s, size_t length) const noexcept
118{
120 for (int i = 0; i < (int)p_enumerators->size(); ++i) {
121 const std::string* x = &((*p_enumerators)[i]);
122 if (x->length() == length) {
123 if (memcmp(s, x->data(), length) == 0) {
124 return i;
125 }
126 }
127 }
128
129 return (-1);
130 }
131
132 return (-2);
133}
134
135const std::string*
136OksAttribute::get_enum_value(const char* s, size_t length) const
137{
139 for (unsigned int i = 0; i < p_enumerators->size(); ++i) {
140 const std::string* x = &((*p_enumerators)[i]);
141 if (x->length() == length) {
142 if (memcmp(s, x->data(), length) == 0) {
143 return x;
144 }
145 }
146 }
147
148 std::ostringstream text;
149 text << "value \'" << s << "\' is out of range \'" << get_range() << '\'';
150 throw std::runtime_error(text.str().c_str());
151 }
152
153 throw std::runtime_error("attribute is not enumeration");
154}
155
156uint16_t
157OksAttribute::get_enum_value(const OksData& d) const noexcept
158{
159 const std::string* p_enumerators_first(&((*p_enumerators)[0]));
160 return (d.data.ENUMERATION - p_enumerators_first);
161}
162
163void
165{
166 if (!a->get_range().empty() && a->get_data_type() != OksData::class_type) {
167 try {
168 OksData d;
169 d.set_init_value(a, false);
170 d.check_range(a);
171 } catch (std::exception& ex) {
172 std::ostringstream text;
173 text << "failed to set initial value \'" << a->get_init_value() << "\' of attribute \'" << a->get_name()
174 << "\':\n"
175 << ex.what();
176 throw std::runtime_error(text.str().c_str());
177 }
178 }
179}
180
181OksAttribute::OksAttribute(const std::string& nm, OksClass* p)
182 : p_name(nm)
184 , p_multi_values(false)
185 , p_no_null(false)
187 , p_class(p)
188 , p_enumerators(nullptr)
189 , p_range_obj(nullptr)
190 , p_ordered(false)
191
192{
193 validate_not_empty(p_name, "attribute name");
194}
195
196OksAttribute::OksAttribute(const std::string& nm,
197 const std::string& t,
198 bool is_mv,
199 const std::string& r,
200 const std::string& init_v,
201 const std::string& ds,
202 bool no_null,
203 Format f,
204 OksClass* p)
205 : p_name(nm)
206 , p_range(r)
208 , p_multi_values(is_mv)
209 , p_no_null(no_null)
210 , p_init_value(init_v)
211 , p_format(f)
212 , p_description(ds)
213 , p_class(p)
214 , p_enumerators(nullptr)
215 , p_range_obj(nullptr)
216 , p_ordered(false)
217{
218 set_type(t, true);
219 validate_not_empty(p_name, "attribute name");
220 init_enum();
221 init_range();
222 // cannot call set_init_data() because of the CLASS data type, since other class may not be known yet;
223 // initialize the init_data in the register_all_classes() call
224}
225
226bool
228{
229 return ((this == &a) ||
230 ((p_name == a.p_name) && (p_range == a.p_range) && (p_data_type == a.p_data_type) &&
233}
234
235std::ostream&
236operator<<(std::ostream& s, const OksAttribute& a)
237{
238 s << "Attribute name: \"" << a.p_name
239 << "\"\n"
240 " type: \""
241 << a.get_type()
242 << "\"\n"
243 " range: \""
244 << a.p_range << "\"\n";
245
246 if (a.is_integer()) {
247 s << " format: \"" << OksAttribute::format2str(a.p_format) << "\"\n";
248 }
249
250 if (a.p_multi_values == true) {
251 s << " is \'multi values\'\n";
252 } else {
253 s << " is \'single value\'\n";
254 }
255
256 s << " initial value: \"" << a.p_init_value
257 << "\"\n"
258 " has description: \""
259 << a.p_description << "\"\n"
260 << (a.p_no_null == true ? " can not be null\n" : " can be null\n") << " is "
261 << (a.p_ordered == true ? "ordered" : "unordered") << std::endl;
262
263 return s;
264}
265
266void
268{
269 if (p_data_type == OksData::class_type && p_init_value.empty() && p_multi_values == false) {
270 std::ostringstream text;
271 text << "single-value attribute \"" << p_name << "\" is of \"class_type\" and has empty init value";
272 throw std::runtime_error(text.str().c_str());
273 }
274
276
277 s.put(" ");
278 s.put_start_tag(attribute_xml_tag, sizeof(attribute_xml_tag) - 1);
279
280 s.put_attribute(name_xml_attr, sizeof(name_xml_attr) - 1, p_name.c_str());
281
282 if (!p_description.empty())
283 s.put_attribute(description_xml_attr, sizeof(description_xml_attr) - 1, p_description.c_str());
284
285 s.put_attribute(type_xml_attr, sizeof(type_xml_attr) - 1, get_type().c_str());
286
287 if (!p_range.empty())
288 s.put_attribute(range_xml_attr, sizeof(range_xml_attr) - 1, p_range.c_str());
289
291 s.put_attribute(format_xml_attr, sizeof(format_xml_attr) - 1, format2str(p_format));
292
293 if (p_multi_values)
295
296 if (!p_init_value.empty())
297 s.put_attribute(init_value_xml_attr, sizeof(init_value_xml_attr) - 1, p_init_value.c_str());
298
299 if (p_no_null)
301
302 if (p_ordered)
303 s.put_attribute(ordered_xml_attr, sizeof(ordered_xml_attr) - 1, xml::bool2str(p_ordered));
304
305 s.put_end_tag();
306}
307
309 : p_data_type(OksData::unknown_type)
310 , p_multi_values(false)
311 , p_no_null(false)
313 , p_class(parent)
314 , p_enumerators(nullptr)
315 , p_range_obj(nullptr)
316 , p_ordered(false)
317{
318 // read attributes of OksAttribute from xml
319
320 try {
321 while (true) {
322 OksXmlAttribute attr(s);
323
324 // check for close of tag
325
326 if (cmp_str1(attr.name(), "/")) {
327 break;
328 }
329
330 // check for known oks-attribute' attributes
331
332 else if (cmp_str4(attr.name(), name_xml_attr))
333 p_name.assign(attr.value(), attr.value_len());
334 else if (cmp_str11(attr.name(), description_xml_attr))
335 p_description.assign(attr.value(), attr.value_len());
336 else if (cmp_str4(attr.name(), type_xml_attr)) {
337 __set_data_type(attr.value(), attr.value_len());
339 throw BadFileData(std::string("Value \'") + attr.value() + "\' is not a valid attribute type",
340 s.get_line_no(),
341 s.get_line_pos());
342 }
343 } else if (cmp_str5(attr.name(), range_xml_attr))
344 p_range.assign(attr.value(), attr.value_len());
345 else if (cmp_str6(attr.name(), format_xml_attr))
346 p_format = str2format(attr.value());
347 else if (cmp_str14(attr.name(), is_multi_value_xml_attr))
349 else if (cmp_str10(attr.name(), init_value_xml_attr))
350 p_init_value.assign(attr.value(), attr.value_len());
351 else if (cmp_str11(attr.name(), is_not_null_xml_attr))
352 p_no_null = xml::str2bool(attr.value());
353 else if (cmp_str7(attr.name(), ordered_xml_attr))
354 p_ordered = xml::str2bool(attr.value());
355 else if (!strcmp(attr.name(), "multi-value-implementation"))
356 s.error_msg("OksAttribute::OksAttribute(OksXmlInputStream&)")
357 << "Obsolete oks-attribute\'s attribute \'" << attr.name() << "\'\n";
358 else
359 s.throw_unexpected_attribute(attr.name());
360 }
361 } catch (exception& e) {
362 throw FailedRead("xml attribute", e);
363 } catch (std::exception& e) {
364 throw FailedRead("xml attribute", e.what());
365 }
366
367 // check validity of read values
368
370 throw FailedRead("oks attribute", BadFileData("attribute type is not set", s.get_line_no(), s.get_line_pos()));
371 }
372
373 try {
374 validate_not_empty(p_name, "attribute name");
375 init_enum();
376 init_range();
377 } catch (std::exception& ex) {
378 throw FailedRead("oks attribute", BadFileData(ex.what(), s.get_line_no(), s.get_line_pos()));
379 }
380
381 if (p_init_value.empty()) {
382 if (p_data_type == OksData::class_type && p_multi_values == false) {
383 std::ostringstream text;
384 text << "single-value attribute \"" << p_name << "\" is of \"class_type\" and has empty init value";
385 throw FailedRead("oks attribute", BadFileData(text.str(), s.get_line_no(), s.get_line_pos()));
386 }
387 } else {
388 if (p_data_type == OksData::date_type || p_data_type == OksData::time_type) {
389 try {
390 OksData _d;
391 if (p_multi_values) {
392 _d.SetValues(p_init_value.c_str(), this);
393 } else {
394 _d.type = p_data_type;
395 _d.SetValue(p_init_value.c_str(), 0);
396 }
397 } catch (exception& ex) {
398 std::ostringstream text;
399 text << "attribute \"" << p_name << "\" has bad init value:\n" << ex.what();
400 throw FailedRead("oks attribute", BadFileData(text.str(), s.get_line_no(), s.get_line_pos()));
401 }
402 }
403 }
404
405 try {
407 } catch (std::exception& ex) {
408 std::ostringstream text;
409 text << "attribute \"" << p_name << "\" has mismatch between init value and range:\n" << ex.what();
410 throw FailedRead("oks attribute", BadFileData(text.str(), s.get_line_no(), s.get_line_pos()));
411 }
412
413 // set_init_data();
414}
415
416OksData::Type
417OksAttribute::get_data_type(const std::string& t) noexcept
418{
419 return get_data_type(t.c_str(), t.size());
420}
421
423OksAttribute::get_data_type(const char* t, size_t len) noexcept
424{
425 switch (len) {
426 case 3:
427 if (cmp_str3n(t, uid_type))
428 return OksData::uid2_type; // "uid"
429 else if (cmp_str3n(t, u32_int_type))
430 return OksData::u32_int_type; // "u32"
431 else if (cmp_str3n(t, s32_int_type))
432 return OksData::s32_int_type; // "s32"
433 else if (cmp_str3n(t, u16_int_type))
434 return OksData::u16_int_type; // "u16"
435 else if (cmp_str3n(t, s16_int_type))
436 return OksData::s16_int_type; // "s16"
437 else if (cmp_str3n(t, s64_int_type))
438 return OksData::s64_int_type; // "s64"
439 else if (cmp_str3n(t, u64_int_type))
440 return OksData::u64_int_type; // "u64"
441 break;
442
443 case 6:
444 if (cmp_str6n(t, string_type))
445 return OksData::string_type; // "string"
446 else if (cmp_str6n(t, double_type))
447 return OksData::double_type; // "double"
448 break;
449
450 case 4:
451 if (cmp_str4n(t, bool_type))
452 return OksData::bool_type; // "bool"
453 else if (cmp_str4n(t, enum_type))
454 return OksData::enum_type; // "enum"
455 else if (cmp_str4n(t, date_type))
456 return OksData::date_type; // "date"
457 else if (cmp_str4n(t, time_type))
458 return OksData::time_type; // "time"
459 break;
460
461 case 5:
462 if (cmp_str5n(t, float_type))
463 return OksData::float_type; // "float"
464 else if (cmp_str5n(t, class_type))
465 return OksData::class_type; // "class"
466 break;
467
468 case 2:
469 if (cmp_str2n(t, s8_int_type))
470 return OksData::s8_int_type; // "s8"
471 else if (cmp_str2n(t, u8_int_type))
472 return OksData::u8_int_type; // "u8"
473 break;
474 }
475
477}
478
479const std::string&
481{
482 static std::string __types[] = {
483 "unknown", // unknown_type = 0
484 "s8", // s8_int_type = 1
485 "u8", // u8_int_type = 2
486 "s16", // s16_int_type = 3,
487 "u16", // u16_int_type = 4,
488 "s32", // s32_int_type = 5,
489 "u32", // u32_int_type = 6,
490 "s64", // s64_int_type = 7,
491 "u64", // u64_int_type = 8,
492 "float", // float_type = 9,
493 "double", // double_type = 10,
494 "bool", // bool_type = 11,
495 "class", // class_type = 12,
496 "object", // object_type = 13,
497 "date", // date_type = 14,
498 "time", // time_type = 15,
499 "string", // string_type = 16,
500 "list", // list_type = 17,
501 "uid", // uid_type = 18,
502 "uid2", // uid2_type = 19,
503 "enum" // enum_type = 20
504 };
505
506 return __types[(int)p_data_type];
507}
508
509void
510OksAttribute::set_type(const std::string& t, bool skip_init)
511{
513
514 if (p_dt == OksData::unknown_type) {
515 std::ostringstream text;
516 text << "the type \'" << t << "\' is not valid";
517 throw SetOperationFailed("OksAttribute::set_type", text.str());
518 }
519
520 if (p_data_type == p_dt)
521 return;
522
523 if (p_class)
524 p_class->lock_file("OksAttribute::set_type");
525
526 p_data_type = p_dt;
527
528 if (skip_init == false) {
529 try {
530 init_enum();
531 init_range();
532 } catch (std::exception& ex) {
533 throw SetOperationFailed("OksAttribute::set_type", ex.what());
534 }
535 }
536
537 if (p_class) {
538 p_class->registrate_attribute_change(this);
539 p_class->registrate_class_change(OksClass::ChangeAttributeType, (const void*)this);
540 }
541}
542
543void
544OksAttribute::set_name(const std::string& new_name)
545{
546 // ignore when name is the same
547
548 if (p_name == new_name)
549 return;
550
551 // additional checks are required,
552 // if the attribute already belongs to some class
553
554 if (p_class) {
555 // check allowed length for attribute name
556
557 try {
558 validate_not_empty(new_name, "name");
559 } catch (std::exception& ex) {
560 throw SetOperationFailed("OksAttribute::set_name", ex.what());
561 }
562
563 // having a direct attribute with the same name is an error
564
565 if (p_class->find_direct_attribute(new_name) != 0) {
566 std::ostringstream text;
567 text << "Class \"" << p_class->get_name() << "\" already has direct attribute \"" << new_name << '\"';
568 throw SetOperationFailed("OksAttribute::set_name", text.str());
569 }
570
571 // check that the file can be updated
572
573 p_class->lock_file("OksAttribute::set_name");
574
575 // probably a non-direct attribute already exists
576
577 OksAttribute* a = p_class->find_attribute(new_name);
578
579 // change the name
580
581 p_name = new_name;
582
583 // registrate the change
584
585 p_class->registrate_class_change(OksClass::ChangeAttributesList, (const void*)a);
586 } else {
587 p_name = new_name;
588 }
589}
590
591void
593{
594 if (p_multi_values != is_mv) {
595 if (p_class)
596 p_class->lock_file("OksAttribute::set_is_multi_values");
597
598 p_multi_values = is_mv;
599
600 if (p_class) {
601 p_class->registrate_class_change(OksClass::ChangeAttributeMultiValueCardinality, (const void*)this);
602 p_class->registrate_attribute_change(this);
603 }
604 }
605}
606
607void
608OksAttribute::set_init_value(const std::string& init_v)
609{
610 if (p_init_value != init_v) {
611 std::string old_value = p_init_value;
612
613 if (p_class)
614 p_class->lock_file("OksAttribute::set_init_value");
615
616 p_init_value = init_v;
617
618 try {
620 } catch (...) {
621 p_init_value = old_value;
622 throw;
623 }
624
625 if (p_class)
626 p_class->registrate_class_change(OksClass::ChangeAttributeInitValue, (const void*)this);
627 }
628}
629
630void
631OksAttribute::set_description(const std::string& ds)
632{
633 if (p_description != ds) {
634 if (p_class)
635 p_class->lock_file("OksAttribute::set_description");
636
637 p_description = ds;
638
639 if (p_class)
640 p_class->registrate_class_change(OksClass::ChangeAttributeDescription, (const void*)this);
641 }
642}
643
644void
646{
647 if (p_no_null != no_null) {
648 if (p_class)
649 p_class->lock_file("OksAttribute::set_is_no_null");
650
651 p_no_null = no_null;
652
653 if (p_class)
654 p_class->registrate_class_change(OksClass::ChangeAttributeIsNoNull, (const void*)this);
655 }
656}
657
658void
660{
661 if (f != p_format) {
662 if (p_class)
663 p_class->lock_file("OksAttribute::set_format");
664
665 p_format = f;
666
667 if (p_class)
668 p_class->registrate_class_change(OksClass::ChangeAttributeFormat, (const void*)this);
669 }
670}
671
672void
673OksAttribute::set_range(const std::string& s)
674{
675 if (s != p_range) {
676 std::string old_value = p_range;
677
678 if (p_class)
679 p_class->lock_file("OksAttribute::set_range");
680
681 p_range.erase();
682 int count = 0;
683 Oks::Tokenizer t(s, ", \t");
684 std::string token;
685
686 while (t.next(token)) {
687 if (count++ != 0) {
688 p_range += ',';
689 }
690
691 p_range += token;
692 }
693
694 if (count != 0) {
696 p_range.erase();
697 throw SetOperationFailed("OksAttribute::set_range", "boolean type can't have user-defined range!");
698 }
699 }
700
701 try {
702 init_enum();
703 init_range();
705 } catch (std::exception& ex) {
706 p_range = old_value;
707
708 try {
709 init_enum();
710 } catch (...) {
711 ;
712 }
713
714 try {
715 init_range();
716 } catch (...) {
717 ;
718 }
719
720 throw SetOperationFailed("OksAttribute::set_range", ex.what());
721 }
722
723 if (p_class)
724 p_class->registrate_class_change(OksClass::ChangeAttributeRange, (const void*)this);
725 }
726}
727
728bool
729OksAttribute::find_token(const char* token, const char* range) noexcept
730{
731 const char* p;
732
733 if (token && (p = strstr(range, token)) != 0) {
734 int len = strlen(token);
735
736 do {
737 if (((p != range) && (p[-1] != ',')) || ((p[len] != ',') && (p[len] != '\0'))) {
738 p = strstr(p + 1, token);
739 } else {
740 return true;
741 }
742
743 } while (p != 0);
744 }
745
746 return false;
747}
748
749inline bool
750is_star(const std::string& s)
751{
752 return (s.size() == 1 && s[0] == '*');
753}
754
755void
756OksRange::reset(const std::string& range, OksAttribute* a)
757{
758 clear();
759
761 if (!range.empty()) {
762 Oks::Tokenizer t(range, ",");
763 std::string token, token1, token2;
764
765 while (t.next(token)) {
766 if (is_star(token)) {
767 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' allows any value";
768 clear();
769 return;
770 }
771
772 static const char __dot_dot_str[] = "..";
773 std::string::size_type p = token.find(__dot_dot_str, 0, (sizeof(__dot_dot_str) - 1));
774
775 bool pi; // if true, then it is plus infinity, i.e. x..*
776
777 if (p != std::string::npos) {
778 token1.assign(token, 0, p);
779 token2.assign(token, p + 2, std::string::npos);
780 pi = (is_star(token2));
781 } else {
782 token1.assign(token);
783 token2.clear();
784 pi = false;
785 }
786
787 bool mi = (is_star(token1)); // if true, then it is minus infinity, i.e. *..x
788
789 if (mi && pi) {
790 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' allows any value";
791 clear();
792 return;
793 }
794
795 OksData d1, d2;
796
797 if (!mi) {
798 d1.type = a->get_data_type();
799 d1.ReadFrom(token1, a);
800 }
801
802 if (token2.empty()) {
803 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' defines equality condition";
804 m_equal.emplace_back(d1);
805 } else {
806 if (!pi) {
807 d2.type = a->get_data_type();
808 d2.ReadFrom(token2, a);
809 }
810
811 if (mi) {
812 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' defines smaller condition";
813 m_less.emplace_back(d2);
814 } else if (pi) {
815 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' defines greater condition";
816 m_great.emplace_back(d1);
817 } else {
818 TLOG_DEBUG(2) << "token \'" << token << "\' of \'" << range << "\' defines interval condition";
819 m_interval.emplace_back(d1, d2);
820 }
821 }
822 }
823 }
824 } else {
825 try {
826 m_like.emplace_back(range);
827 } catch (std::exception& ex) {
828 throw BadReqExp(range, ex.what());
829 }
830 }
831}
832
833bool
835{
836 for (const auto& x : m_less) {
837 if (d <= x)
838 return true;
839 }
840
841 for (const auto& x : m_great) {
842 if (d >= x)
843 return true;
844 }
845
846 for (const auto& x : m_equal) {
847 if (d == x)
848 return true;
849 }
850
851 for (const auto& x : m_interval) {
852 if (d >= x.first && d <= x.second)
853 return true;
854 }
855
856 for (const auto& x : m_like) {
858 return true;
859
860 if (boost::regex_match(d.str(), x))
861 return true;
862 }
863
864 return false;
865}
866
867} // namespace oks
868} // namespace dunedaq
BadFileData(const std::string &what, unsigned long line_no, unsigned long line_pos, int level_arg=0) noexcept
Definition xml.hpp:49
FailedRead(const std::string &what, const exception &reason) noexcept
Definition xml.hpp:67
OKS attribute class.
Definition attribute.hpp:94
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
friend std::ostream & operator<<(std::ostream &, const OksAttribute &)
equality operator
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
Definition attribute.cpp:61
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
Definition attribute.cpp:73
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
Definition attribute.cpp:55
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
Definition attribute.cpp:67
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.
@ ChangeAttributeMultiValueCardinality
Definition class.hpp:851
static bool get_skip_string_range()
Get status of string range validator.
Definition kernel.hpp:822
bool validate(const OksData &) const
OksRange(const std::string &range, OksAttribute *a)
Definition attribute.hpp:47
std::list< std::pair< OksData, OksData > > m_interval
Definition attribute.hpp:63
std::list< OksData > m_less
Definition attribute.hpp:61
std::list< OksData > m_great
Definition attribute.hpp:64
std::list< boost::regex > m_like
Definition attribute.hpp:65
std::list< OksData > m_equal
Definition attribute.hpp:62
void reset(const std::string &range, OksAttribute *a)
String tokenizer.
Definition defs.hpp:59
const std::string next()
Definition time.cpp:190
virtual const char * what() const noexcept
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
const char * bool2str(bool b) noexcept
Definition xml.hpp:29
bool str2bool(const char *s) noexcept
Definition xml.hpp:36
bool cmp_str2n(const char *s1, const char s2[2])
Definition cstring.hpp:27
bool cmp_str1(const char *s1, const char s2[2])
Definition cstring.hpp:15
bool cmp_str4(const char *s1, const char s2[5])
Definition cstring.hpp:45
bool cmp_str6(const char *s1, const char s2[7])
Definition cstring.hpp:69
bool cmp_str10(const char *s1, const char s2[11])
Definition cstring.hpp:111
bool cmp_str5n(const char *s1, const char s2[5])
Definition cstring.hpp:63
bool cmp_str3n(const char *s1, const char s2[3])
Definition cstring.hpp:39
void validate_init2range(const OksAttribute *a)
void validate_not_empty(const std::string &value, const char *name)
bool is_star(const std::string &s)
bool cmp_str5(const char *s1, const char s2[6])
Definition cstring.hpp:57
bool cmp_str11(const char *s1, const char s2[12])
Definition cstring.hpp:117
bool cmp_str3(const char *s1, const char s2[4])
Definition cstring.hpp:33
bool cmp_str6n(const char *s1, const char s2[6])
Definition cstring.hpp:75
bool cmp_str14(const char *s1, const char s2[14])
Definition cstring.hpp:135
bool cmp_str7(const char *s1, const char s2[8])
Definition cstring.hpp:81
bool cmp_str4n(const char *s1, const char s2[4])
Definition cstring.hpp:51
The DUNE-DAQ namespace.
DAC value out of range
Message.
Definition DACNode.hpp:32
Definition ral.hpp:59
Struct OKS data.
Definition object.hpp:510
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 *)
Definition object.hpp:1063
size_t value_len() const
Definition xml.hpp:288