ProteoWizard
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
pwiz::minimxml::SAXParser::Handler::Attributes Class Reference

#include <SAXParser.hpp>

Classes

class  attribute
 

Public Types

typedef std::vector< attributeattribute_list
 

Public Member Functions

 Attributes (const char *_source_text, size_t _source_text_len, bool _autoUnescape)
 
 Attributes ()
 
 Attributes (saxstring &str, bool _autoUnescape)
 
 ~Attributes ()
 
 Attributes (const Attributes &rhs)
 
Attributesoperator= (const Attributes &rhs)
 
void test_invariant () const
 
const char * getTagName () const
 
const char * getTextBuffer () const
 
size_t getSize () const
 
attribute_list::const_iterator begin () const
 
attribute_list::const_iterator end () const
 
attribute_list::const_iterator find (const std::string &name) const
 
const attributefindAttributeByName (const char *name) const
 
const char * findValueByName (const char *name, XMLUnescapeBehavior_t Unescape=XMLUnescapeDefault) const
 

Protected Member Functions

void setParserIndex ()
 
PWIZ_API_DECL void parseAttributes (std::string::size_type &index) const
 
void access () const
 

Protected Attributes

char * textbuff
 
size_t size
 
size_t index
 
size_t index_end
 
bool autoUnescape
 
bool managemem
 
bool firstread
 
attribute_list attrs
 

Detailed Description

Definition at line 351 of file SAXParser.hpp.

Member Typedef Documentation

§ attribute_list

Definition at line 523 of file SAXParser.hpp.

Constructor & Destructor Documentation

§ Attributes() [1/4]

pwiz::minimxml::SAXParser::Handler::Attributes::Attributes ( const char *  _source_text,
size_t  _source_text_len,
bool  _autoUnescape 
)
inline

§ Attributes() [2/4]

pwiz::minimxml::SAXParser::Handler::Attributes::Attributes ( )
inline

§ Attributes() [3/4]

pwiz::minimxml::SAXParser::Handler::Attributes::Attributes ( saxstring str,
bool  _autoUnescape 
)
inline

Definition at line 376 of file SAXParser.hpp.

References pwiz::minimxml::SAXParser::saxstring::data(), and pwiz::minimxml::SAXParser::saxstring::length().

§ ~Attributes()

pwiz::minimxml::SAXParser::Handler::Attributes::~Attributes ( )
inline

Definition at line 385 of file SAXParser.hpp.

§ Attributes() [4/4]

pwiz::minimxml::SAXParser::Handler::Attributes::Attributes ( const Attributes rhs)
inline

Definition at line 390 of file SAXParser.hpp.

391  {
392  textbuff = NULL;
393  *this = rhs;
394  }

Member Function Documentation

§ operator=()

Attributes& pwiz::minimxml::SAXParser::Handler::Attributes::operator= ( const Attributes rhs)
inline

Definition at line 395 of file SAXParser.hpp.

References attrs, autoUnescape, firstread, getTextBuffer(), index, index_end, size, and textbuff.

395  {
396  size = rhs.size;
397  index = rhs.index;
398  index_end = rhs.index_end; // string bounds for attribute parsing
399  autoUnescape = rhs.autoUnescape; // do XML escape of attribute?
400  firstread = rhs.firstread; // may change during const access
401  if (managemem)
402  textbuff = (char *)realloc(textbuff,size+1);
403  else
404  textbuff = (char *)malloc(size+1);
405  managemem = true; // we need to free textbuff at dtor
406  memcpy(textbuff,rhs.textbuff,size+1);
407  attrs.resize(rhs.attrs.size());
408  // now fix up the char ptrs to point to our copy of attribute list
409  for (size_t n=attrs.size();n--;)
410  {
411  attrs[n].name = ((char *)textbuff)+(rhs.attrs[n].getName()-rhs.getTextBuffer());
412  attrs[n].value = ((char *)textbuff)+(rhs.attrs[n].getValuePtr()-rhs.getTextBuffer());
413  }
414  test_invariant(); // everything correct?
415  return *this;
416  }

§ test_invariant()

void pwiz::minimxml::SAXParser::Handler::Attributes::test_invariant ( ) const
inline

Definition at line 418 of file SAXParser.hpp.

References pwiz::msdata::id::value().

419  {
420 #ifdef _DEBUG
421  for (size_t n=attrs.size();n--;)
422  {
423  assert(textbuff != NULL);
424  assert(attrs[n].name>textbuff);
425  assert(attrs[n].value>attrs[n].name);
426  assert(attrs[n].value<textbuff+size);
427  if (n)
428  assert(attrs[n].name>attrs[n-1].value);
429  }
430 #endif
431  }
PWIZ_API_DECL std::string value(const std::string &id, const std::string &name)
convenience function to extract a named value from an id string

§ getTagName()

const char* pwiz::minimxml::SAXParser::Handler::Attributes::getTagName ( ) const
inline

Definition at line 433 of file SAXParser.hpp.

434  { // work area contains tag name
435  test_invariant(); // everything correct?
436  return textbuff+('/'==*textbuff);
437  }

§ getTextBuffer()

const char* pwiz::minimxml::SAXParser::Handler::Attributes::getTextBuffer ( ) const
inline

Definition at line 438 of file SAXParser.hpp.

Referenced by operator=().

439  { // return pointer to our work area
440  test_invariant(); // everything correct?
441  return textbuff;
442  }

§ getSize()

size_t pwiz::minimxml::SAXParser::Handler::Attributes::getSize ( ) const
inline

Definition at line 443 of file SAXParser.hpp.

444  {
445  return size;
446  }

§ setParserIndex()

void pwiz::minimxml::SAXParser::Handler::Attributes::setParserIndex ( )
inlineprotected

Definition at line 455 of file SAXParser.hpp.

456  {
457  // on entry, buffer has form "foo bar="baz" or maybe "foo/"
458  const char *c = textbuff;
459  while (*c && !strchr(" \n\r\t/",*c)) c++;
460  size_t indexNameEnd = c-textbuff;
461  while (*c && strchr(" \n\r\t",*c)) c++;
462  textbuff[indexNameEnd] = 0; // nullterm the name
463  index = c-textbuff; // should point to bar
464  index_end = size;
465  test_invariant(); // everything correct?
466  }

§ begin()

attribute_list::const_iterator pwiz::minimxml::SAXParser::Handler::Attributes::begin ( ) const
inline

Definition at line 527 of file SAXParser.hpp.

Referenced by PrintEventHandler::startElement().

528  {
529  access(); // have we actually parsed the attributes text yet?
530  return attrs.begin();
531  }

§ end()

attribute_list::const_iterator pwiz::minimxml::SAXParser::Handler::Attributes::end ( ) const
inline

Definition at line 532 of file SAXParser.hpp.

Referenced by readAttribute(), and PrintEventHandler::startElement().

533  {
534  access(); // have we actually parsed the attributes text yet?
535  return attrs.end();
536  }

§ find()

attribute_list::const_iterator pwiz::minimxml::SAXParser::Handler::Attributes::find ( const std::string &  name) const
inline

Definition at line 537 of file SAXParser.hpp.

References PWIZ_API_DECL.

Referenced by readAttribute().

538  {
539  attribute_list::const_iterator it;
540  for (it = begin(); it != end() ; it++ )
541  {
542  if (it->matchName(name.c_str()))
543  break; // found it
544  }
545  return it;
546  }
attribute_list::const_iterator end() const
Definition: SAXParser.hpp:532
attribute_list::const_iterator begin() const
Definition: SAXParser.hpp:527

§ parseAttributes()

PWIZ_API_DECL void pwiz::minimxml::SAXParser::Handler::Attributes::parseAttributes ( std::string::size_type &  index) const
protected

§ access()

void pwiz::minimxml::SAXParser::Handler::Attributes::access ( ) const
inlineprotected

Definition at line 551 of file SAXParser.hpp.

552  { // don't parse attributes until asked to
553  test_invariant(); // everything correct?
554  if (firstread) {
555  firstread = false;
557  }
558  test_invariant(); // everything correct?
559  }
PWIZ_API_DECL void parseAttributes(std::string::size_type &index) const

§ findAttributeByName()

const attribute* pwiz::minimxml::SAXParser::Handler::Attributes::findAttributeByName ( const char *  name) const
inline

Definition at line 562 of file SAXParser.hpp.

Referenced by pwiz::minimxml::SAXParser::Handler::getAttribute().

563  {
564  access(); // parse the buffer if we haven't already
565  for (attribute_list::const_iterator it=attrs.begin();it!=attrs.end();it++)
566  {
567  if (it->matchName(name))
568  return &(*it);
569  }
570  return NULL;
571  }

§ findValueByName()

const char* pwiz::minimxml::SAXParser::Handler::Attributes::findValueByName ( const char *  name,
XMLUnescapeBehavior_t  Unescape = XMLUnescapeDefault 
) const
inline

Definition at line 574 of file SAXParser.hpp.

References pwiz::minimxml::SAXParser::Handler::Attributes::attribute::getValuePtr().

Referenced by pwiz::minimxml::SAXParser::Handler::getAttribute().

575  {
576  const attribute *attr = findAttributeByName(name);
577  if (attr)
578  return attr->getValuePtr(Unescape);
579  return NULL;
580  }
const attribute * findAttributeByName(const char *name) const
Definition: SAXParser.hpp:562

Member Data Documentation

§ textbuff

char* pwiz::minimxml::SAXParser::Handler::Attributes::textbuff
mutableprotected

Definition at line 448 of file SAXParser.hpp.

Referenced by operator=().

§ size

size_t pwiz::minimxml::SAXParser::Handler::Attributes::size
protected

Definition at line 449 of file SAXParser.hpp.

Referenced by operator=().

§ index

size_t pwiz::minimxml::SAXParser::Handler::Attributes::index
mutableprotected

Definition at line 450 of file SAXParser.hpp.

Referenced by operator=().

§ index_end

size_t pwiz::minimxml::SAXParser::Handler::Attributes::index_end
mutableprotected

Definition at line 450 of file SAXParser.hpp.

Referenced by operator=().

§ autoUnescape

bool pwiz::minimxml::SAXParser::Handler::Attributes::autoUnescape
protected

Definition at line 451 of file SAXParser.hpp.

Referenced by operator=().

§ managemem

bool pwiz::minimxml::SAXParser::Handler::Attributes::managemem
protected

Definition at line 452 of file SAXParser.hpp.

§ firstread

bool pwiz::minimxml::SAXParser::Handler::Attributes::firstread
mutableprotected

Definition at line 453 of file SAXParser.hpp.

Referenced by operator=().

§ attrs

attribute_list pwiz::minimxml::SAXParser::Handler::Attributes::attrs
mutableprotected

Definition at line 525 of file SAXParser.hpp.

Referenced by operator=().


The documentation for this class was generated from the following file: