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

#include <SAXParser.hpp>

List of all members.

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

Definition at line 523 of file SAXParser.hpp.


Constructor & Destructor Documentation

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

Definition at line 357 of file SAXParser.hpp.

References managemem, setParserIndex(), size, test_invariant(), and textbuff.

:
index(0),index_end(0),autoUnescape(_autoUnescape),firstread(true),attrs()
{
size=_source_text_len;
textbuff = (char *)malloc(size+1);
managemem = true;
memcpy(textbuff,_source_text,size);
textbuff[size] = 0;
setParserIndex(); // ready for eventual parsing
test_invariant(); // everything correct?
};
pwiz::minimxml::SAXParser::Handler::Attributes::Attributes ( )
inline

Definition at line 368 of file SAXParser.hpp.

References managemem, size, test_invariant(), and textbuff.

:
{
size=0;
textbuff = NULL;
managemem = true;
test_invariant(); // everything correct?
};
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(), pwiz::minimxml::SAXParser::saxstring::length(), managemem, setParserIndex(), size, test_invariant(), and textbuff.

:
index(0),index_end(0),autoUnescape(_autoUnescape),firstread(true),attrs()
{
textbuff = str.data();
size=str.length();
managemem = false; // we don't have to free this
setParserIndex(); // ready for eventual parsing
test_invariant(); // everything correct?
};
pwiz::minimxml::SAXParser::Handler::Attributes::~Attributes ( )
inline

Definition at line 385 of file SAXParser.hpp.

References managemem, and textbuff.

{
if (managemem)
free(textbuff);
}
pwiz::minimxml::SAXParser::Handler::Attributes::Attributes ( const Attributes rhs)
inline

Definition at line 390 of file SAXParser.hpp.

References textbuff.

{
textbuff = NULL;
*this = rhs;
}

Member Function Documentation

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, managemem, size, test_invariant(), and textbuff.

{
size = rhs.size;
index = rhs.index;
index_end = rhs.index_end; // string bounds for attribute parsing
autoUnescape = rhs.autoUnescape; // do XML escape of attribute?
firstread = rhs.firstread; // may change during const access
if (managemem)
textbuff = (char *)realloc(textbuff,size+1);
else
textbuff = (char *)malloc(size+1);
managemem = true; // we need to free textbuff at dtor
memcpy(textbuff,rhs.textbuff,size+1);
attrs.resize(rhs.attrs.size());
// now fix up the char ptrs to point to our copy of attribute list
for (size_t n=attrs.size();n--;)
{
attrs[n].name = ((char *)textbuff)+(rhs.attrs[n].getName()-rhs.getTextBuffer());
attrs[n].value = ((char *)textbuff)+(rhs.attrs[n].getValuePtr()-rhs.getTextBuffer());
}
test_invariant(); // everything correct?
return *this;
}
void pwiz::minimxml::SAXParser::Handler::Attributes::test_invariant ( ) const
inline

Definition at line 418 of file SAXParser.hpp.

References attrs, size, textbuff, and pwiz::msdata::id::value().

Referenced by access(), Attributes(), getTagName(), getTextBuffer(), operator=(), and setParserIndex().

{
#ifdef _DEBUG
for (size_t n=attrs.size();n--;)
{
assert(textbuff != NULL);
assert(attrs[n].name>textbuff);
assert(attrs[n].value>attrs[n].name);
assert(attrs[n].value<textbuff+size);
if (n)
assert(attrs[n].name>attrs[n-1].value);
}
#endif
}
const char* pwiz::minimxml::SAXParser::Handler::Attributes::getTagName ( ) const
inline

Definition at line 433 of file SAXParser.hpp.

References test_invariant(), and textbuff.

{ // work area contains tag name
test_invariant(); // everything correct?
return textbuff+('/'==*textbuff);
}
const char* pwiz::minimxml::SAXParser::Handler::Attributes::getTextBuffer ( ) const
inline

Definition at line 438 of file SAXParser.hpp.

References test_invariant(), and textbuff.

Referenced by operator=().

{ // return pointer to our work area
test_invariant(); // everything correct?
return textbuff;
}
size_t pwiz::minimxml::SAXParser::Handler::Attributes::getSize ( ) const
inline

Definition at line 443 of file SAXParser.hpp.

References size.

{
return size;
}
void pwiz::minimxml::SAXParser::Handler::Attributes::setParserIndex ( )
inlineprotected

Definition at line 455 of file SAXParser.hpp.

References index, index_end, size, test_invariant(), and textbuff.

Referenced by Attributes().

{
// on entry, buffer has form "foo bar="baz" or maybe "foo/"
const char *c = textbuff;
while (*c && !strchr(" \n\r\t/",*c)) c++;
size_t indexNameEnd = c-textbuff;
while (*c && strchr(" \n\r\t",*c)) c++;
textbuff[indexNameEnd] = 0; // nullterm the name
index = c-textbuff; // should point to bar
test_invariant(); // everything correct?
}
attribute_list::const_iterator pwiz::minimxml::SAXParser::Handler::Attributes::begin ( ) const
inline

Definition at line 527 of file SAXParser.hpp.

References access(), and attrs.

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

{
access(); // have we actually parsed the attributes text yet?
return attrs.begin();
}
attribute_list::const_iterator pwiz::minimxml::SAXParser::Handler::Attributes::end ( ) const
inline

Definition at line 532 of file SAXParser.hpp.

References access(), and attrs.

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

{
access(); // have we actually parsed the attributes text yet?
return attrs.end();
}
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 begin(), and end().

Referenced by readAttribute().

{
attribute_list::const_iterator it;
for (it = begin(); it != end() ; it++ )
{
if (it->matchName(name.c_str()))
break; // found it
}
return it;
}
PWIZ_API_DECL void pwiz::minimxml::SAXParser::Handler::Attributes::parseAttributes ( std::string::size_type &  index) const
protected

Referenced by access().

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

Definition at line 551 of file SAXParser.hpp.

References firstread, index, parseAttributes(), and test_invariant().

Referenced by begin(), end(), and findAttributeByName().

{ // don't parse attributes until asked to
test_invariant(); // everything correct?
if (firstread) {
firstread = false;
}
test_invariant(); // everything correct?
}
const attribute* pwiz::minimxml::SAXParser::Handler::Attributes::findAttributeByName ( const char *  name) const
inline

Definition at line 562 of file SAXParser.hpp.

References access(), and attrs.

Referenced by findValueByName(), and pwiz::minimxml::SAXParser::Handler::getAttribute().

{
access(); // parse the buffer if we haven't already
for (attribute_list::const_iterator it=attrs.begin();it!=attrs.end();it++)
{
if (it->matchName(name))
return &(*it);
}
return NULL;
}
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 findAttributeByName(), and pwiz::minimxml::SAXParser::Handler::Attributes::attribute::getValuePtr().

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

{
const attribute *attr = findAttributeByName(name);
if (attr)
return attr->getValuePtr(Unescape);
return NULL;
}

Member Data Documentation

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

Definition at line 448 of file SAXParser.hpp.

Referenced by Attributes(), getTagName(), getTextBuffer(), operator=(), setParserIndex(), test_invariant(), and ~Attributes().

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

Definition at line 449 of file SAXParser.hpp.

Referenced by Attributes(), getSize(), operator=(), setParserIndex(), and test_invariant().

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

Definition at line 450 of file SAXParser.hpp.

Referenced by access(), operator=(), and setParserIndex().

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

Definition at line 450 of file SAXParser.hpp.

Referenced by operator=(), and setParserIndex().

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

Definition at line 451 of file SAXParser.hpp.

Referenced by operator=().

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

Definition at line 452 of file SAXParser.hpp.

Referenced by Attributes(), operator=(), and ~Attributes().

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

Definition at line 453 of file SAXParser.hpp.

Referenced by access(), and operator=().

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

Definition at line 525 of file SAXParser.hpp.

Referenced by begin(), end(), findAttributeByName(), operator=(), and test_invariant().


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