19 : myRegistry_( myreg ),
26 : myRegistry_( myreg ),
39 DCOUT_V(
'P',
"DDXMLElement::preProcessElementBase default, do nothing) started-completed.");
45 const std::vector<std::string> &
names,
46 const std::vector<std::string> &
values,
53 for (
size_t i = 0;
i < names.size(); ++
i)
56 tAttributes.insert(std::make_pair(names[
i], values[i]));
60 DCOUT_V(
'P',
"DDXMLElement::loadAttributes completed. " << *
this);
76 static const std::string ldef;
95 std::string ns = defaultNS;
101 if ( defaultNS ==
"!" ) {
105 std::string rn =
name;
106 size_t foundColon= name.find(
':');
107 if (foundColon != std::string::npos) {
108 ns = name.substr(0,foundColon);
109 rn = name.substr(foundColon+1);
116 std::string
msg =
"DDXMLElement:getDDName failed. It was asked to make ";
117 msg +=
"a DDName using attribute: " + attname;
118 msg +=
" in position: " +
itostr(
int(aIndex)) +
". There are ";
121 return DDName(
"justToCompile",
"justToCompile");
161 static const std::string sts;
164 DDXMLAttribute::const_iterator it =
attributes_[aIndex].find(name);
167 DCOUT_V(
'P',
"WARNING: DDXMLElement::get did not find the requested attribute: " << name << std::endl << *
this);
173 std::string
msg =
"DDXMLElement:get failed. It was asked for attribute " +
name;
174 msg +=
" in position " +
itostr(
int(aIndex)) +
" when there are only ";
183 std::vector<std::string>
189 std::vector<std::string> tv;
198 DCOUT_V(
'P',
"DDXMLElement::getAttribute found attribute named " << name <<
" in a map of size " <<
size());
208 DCOUT_V(
'P',
"DDXMLAttributeAccumulator::getAttribute was asked to provide a std::vector of values for an attribute named " << name <<
" but there was no such attribute.");
219 DCOUT_V(
'P',
"DDXMLElement::processElementBase (default, do nothing) started-completed");
228 text_.push_back(inText);
235 static const std::string cr(
"\n");
236 if (
text_.size() > 0) {
241 std::string
msg =
"DDXMLElement::appendText could not append to non-existent text.";
249 if (tindex >
text_.size()) {
250 std::string
msg =
"DDXMLElement::getText tindex is greater than text_.size()).";
253 return text_[tindex];
259 if (
text_.size() != 0)
273 os <<
"Output of current element attributes:" << std::endl;
274 for (std::vector<DDXMLAttribute>::const_iterator itv =
attributes_.begin();
277 for (DDXMLAttribute::const_iterator it = itv->begin();
278 it != itv->end(); ++it)
279 os << it->first <<
" = " << it->second <<
"\t";
286 const std::string&
name )
290 DDXMLAttribute::const_iterator itnv =
attributes_[
i].find(name);
292 tv.push_back(itnv->second);
305 std::vector<DDXMLAttribute>::const_iterator
312 std::vector<DDXMLAttribute>::const_iterator
319 std::vector<DDXMLAttribute>::const_iterator&
348 std::ostringstream ostr;
362 std::string
msg = keyMessage +
"\n";
virtual bool isEmpty(void) const
Have any elements of this type been encountered but not processed?
std::string parentElement_
std::vector< DDXMLAttribute >::const_iterator & operator++(int inc)
Allow the elements of this type to be iterated over using ++ operator.
static std::string itostr(int i)
WARNING: abused by other classes in this system: yet another conversion from int to std::string...
void appendText(const std::string &inText)
append to the current (i.e. most recently added)
An exception for DDD errors.
void setParent(const std::string &pename)
Set parent element name to central list of names.
virtual const DDXMLAttribute & getAttributeSet(size_t aIndex=0) const
Get a "row" of attributes, i.e. one attribute set.
virtual const std::string & get(const std::string &name, size_t aIndex=0) const
Returns a specific value from the aIndex set of attributes.
void throwError(const std::string &keyMessage) const
format std::string for throw an error.
DDName is used to identify DDD entities uniquely.
virtual void processElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv)
Processing the element.
const std::string & parent(void) const
access to parent element name
void appendAttributes(std::vector< std::string > &tv, const std::string &name)
behind the scenes appending to pAttributes...
std::ostream & operator<<(std::ostream &out, const ALILine &li)
type of data representation of DDCompactView
std::map< std::string, std::string > DDXMLAttribute
virtual void preProcessElement(const std::string &name, const std::string &nmspace, DDCompactView &cpv)
Called by loadAttributes AFTER attributes are loaded.
void loadText(const std::string &inText)
Used to load both text and XML comments into this object.
void setSelf(const std::string &sename)
Set self element name to central list of names.
virtual std::vector< DDXMLAttribute >::const_iterator end(void)
void loadAttributes(const std::string &elemName, const std::vector< std::string > &names, const std::vector< std::string > &values, const std::string &nmspace, DDCompactView &cpv)
Load the element attributes.
virtual size_t size(void) const
Number of elements accumulated.
std::vector< DDXMLAttribute >::const_iterator myIter_
std::vector< DDXMLAttribute > attributes_
virtual bool gotText(void) const
gotText()? kind of like gotMilk? Yes = text has already been encountered.
virtual std::vector< std::string > getVectorAttribute(const std::string &name)
Returns a set of values as a std::vector of strings, given the attribute name.
AttrAccumType attributeAccumulator_
#define DCOUT_V(M_v_Y, M_v_S)
virtual ~DDXMLElement(void)
Destructor.
This is a base class for processing XML elements in the DDD.
virtual const std::string & getAttribute(const std::string &name) const
Access to attributes by name.
virtual std::vector< DDXMLAttribute >::const_iterator begin(void)
virtual void stream(std::ostream &os) const
Allow for the elements to have their own streaming method, but also provide a default.
The main class for processing parsed elements.
virtual void clear(void)
clear this element's contents.
DDXMLElement(DDLElementRegistry *myreg)
Constructor.
virtual const DDName getDDName(const std::string &defaultNS, const std::string &attname=std::string("name"), size_t aIndex=0)
static const HistoName names[]
const std::string getText(size_t tindex=0) const
retrieve the text blob.
std::vector< std::string > text_