DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oks::OksXmlAttribute Struct Reference

#include <xml.hpp>

Collaboration diagram for dunedaq::oks::OksXmlAttribute:
[legend]

Public Member Functions

 OksXmlAttribute (OksXmlInputStream &s)
char * name () const
char * value () const
size_t value_len () const

Public Attributes

OksXmlToken & p_name
OksXmlToken & p_value
size_t p_value_len

Detailed Description

The struct is used to read pair of strings (attribute name and value) from oks xml input stream.

Definition at line 277 of file xml.hpp.

Constructor & Destructor Documentation

◆ OksXmlAttribute()

dunedaq::oks::OksXmlAttribute::OksXmlAttribute ( OksXmlInputStream & s)

Definition at line 555 of file xml.cpp.

556 : p_name(*s.m_v1)
557 , p_value(*s.m_v2)
558{
559 unsigned long start_line_no = s.line_no;
560 unsigned long start_line_pos = s.line_pos;
561
562 try {
563 char c = s.get_first_non_empty();
564
565 start_line_no = s.line_no;
566 start_line_pos = s.line_pos;
567
568 size_t pos = s.get_token2(c, '=', '>', p_name);
569
570 char* m_buf_ptr(p_name.m_buf);
571
572 // skip empty symbols
573
574 for (char* str(m_buf_ptr + pos - 1); str >= m_buf_ptr; --str) {
575 if (*str == ' ' || *str == '\n' || *str == '\r' || *str == '\t') {
576 *str = 0;
577 } else {
578 break;
579 }
580 }
581
582 if (c == '>' || c == '/' || c == '?')
583 return; // end of attribute
584
585 c = s.get_first_non_empty();
586
587 if (__builtin_expect((c != '\"'), 0)) {
588 __throw_bad_file_data_unexpected_symbol("start-of-attribute-value", '\"', c, s.line_no, s.line_pos);
589 }
590
591 p_value_len = s.get_token('\"', p_value);
592
593 TLOG_DEBUG(8) << "read attribute \'" << m_buf_ptr << "\' and value \'" << p_value.m_buf << '\'';
594 } catch (std::exception& ex) {
595 throw oks::BadFileData(
596 std::string(ex.what()) + " when read xml attribute started at", start_line_no, start_line_pos);
597 }
598}
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
static void __throw_bad_file_data_unexpected_symbol(const char *what, const char expected, const char read, unsigned long l, unsigned long p)
Definition xml.cpp:110

Member Function Documentation

◆ name()

char * dunedaq::oks::OksXmlAttribute::name ( ) const
inline

Definition at line 286 of file xml.hpp.

286{ return p_name.m_buf; }

◆ value()

char * dunedaq::oks::OksXmlAttribute::value ( ) const
inline

Definition at line 287 of file xml.hpp.

287{ return p_value.m_buf; }

◆ value_len()

size_t dunedaq::oks::OksXmlAttribute::value_len ( ) const
inline

Definition at line 288 of file xml.hpp.

288{ return p_value_len; }

Member Data Documentation

◆ p_name

OksXmlToken& dunedaq::oks::OksXmlAttribute::p_name

Definition at line 280 of file xml.hpp.

◆ p_value

OksXmlToken& dunedaq::oks::OksXmlAttribute::p_value

Definition at line 281 of file xml.hpp.

◆ p_value_len

size_t dunedaq::oks::OksXmlAttribute::p_value_len

Definition at line 282 of file xml.hpp.


The documentation for this struct was generated from the following files: