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

OksXmlTokenp_name
 
OksXmlTokenp_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 294 of file xml.hpp.

Constructor & Destructor Documentation

◆ OksXmlAttribute()

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

Definition at line 531 of file xml.cpp.

531 : p_name(*s.m_v1), p_value(*s.m_v2)
532{
533 unsigned long start_line_no = s.line_no;
534 unsigned long start_line_pos = s.line_pos;
535
536 try {
537 char c = s.get_first_non_empty();
538
539 start_line_no = s.line_no;
540 start_line_pos = s.line_pos;
541
542 size_t pos = s.get_token2(c, '=', '>', p_name);
543
544 char * m_buf_ptr(p_name.m_buf);
545
546 // skip empty symbols
547
548 for(char * str(m_buf_ptr + pos - 1); str >= m_buf_ptr; --str) {
549 if(*str == ' ' || *str == '\n' || *str == '\r' || *str == '\t') {
550 *str = 0;
551 }
552 else {
553 break;
554 }
555 }
556
557 if(c == '>' || c == '/' || c == '?') return; // end of attribute
558
559 c = s.get_first_non_empty();
560
561 if( __builtin_expect((c != '\"'), 0) ) {
562 __throw_bad_file_data_unexpected_symbol("start-of-attribute-value", '\"', c, s.line_no, s.line_pos);
563 }
564
565 p_value_len = s.get_token('\"', p_value);
566
567 TLOG_DEBUG(8) << "read attribute \'" << m_buf_ptr << "\' and value \'" << p_value.m_buf << '\'';
568 }
569 catch(std::exception& ex) {
570 throw oks::BadFileData(std::string(ex.what()) + " when read xml attribute started at", start_line_no, start_line_pos);
571 }
572}
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
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:106

Member Function Documentation

◆ name()

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

Definition at line 302 of file xml.hpp.

302{return p_name.m_buf;}

◆ value()

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

Definition at line 303 of file xml.hpp.

303{return p_value.m_buf;}

◆ value_len()

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

Definition at line 304 of file xml.hpp.

304{return p_value_len;}

Member Data Documentation

◆ p_name

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

Definition at line 296 of file xml.hpp.

◆ p_value

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

Definition at line 297 of file xml.hpp.

◆ p_value_len

size_t dunedaq::oks::OksXmlAttribute::p_value_len

Definition at line 298 of file xml.hpp.


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