41 for (i = 0; ((
buf[i]) && (!isalpha(
buf[i]))); i++);
43 if (strchr(
"\t\r\n ",
buf[i])) {
47 for (; ((
buf[i]) && (!isalpha(
buf[i]))); i++);
52 for (; ((
buf[i]) && (!strchr(
" =",
buf[i]))); i++);
57 name =
new char [ (i-start) + 1 ];
58 strncpy(name,
buf+start, i-start);
67 for (;
buf[i] ==
' '; i++) ;
75 for (;
buf[i] ==
' '; i++) ;
78 char quoteChar =
buf[i];
85 for (; ((
buf[i]) && (
buf[i] != quoteChar)); i++);
90 value =
new char [ (i-start) + 1 ];
92 strncpy(value,
buf+start, i-start);
108 if (!strchr(
" \t\r\n>\t",
buf[i]))
113 if (name)
delete []
name;
114 if (value)
delete [] value;
131 int len = (int)strlen(t.
buf);
132 buf =
new char[len + 1];
133 memcpy(
buf, t.
buf, len + 1);
136 int len = (int)strlen(t.
name);
137 name =
new char[len + 1];
162 for (i = 0; ((tagString[i]) && (!isalpha(tagString[i]))); i++) {
163 if (tagString[i] ==
'/')
167 for (; ((tagString[i]) && (!strchr(
"\t\r\n />", tagString[i]))); i++);
171 name =
new char [ (i-start) + 1 ];
172 strncpy(
name, tagString+start, i-start);
174 if (tagString[i] ==
'/')
195 retVal.push_back(it->first.c_str());
202 for (; (buf && partNum); partNum--) {
203 buf = strchr(buf, partSplit);
208 const char *end = strchr(buf, partSplit);
221 for (count = 0;
buf; count++) {
222 buf = strchr(buf, partSplit);
235 StringPairMap::const_iterator it =
attributes.find(attribName);
237 const char *retVal = 0;
239 retVal = it->second.c_str();
241 if ((retVal) && (partNum > -1))
242 retVal =
getPart(retVal, partNum, partSplit);
248 const char *
XMLTag::setAttribute(
const char *attribName,
const char *attribValue,
int partNum,
char partSplit) {
257 for (
int i = 0; i < attrCount; i++) {
260 newVal += attribValue;
268 newVal +=
getPart(wholeAttr, i, partSplit);
272 if (newVal.
length()) newVal--;
273 attribValue = (!attribValue && !newVal.
length()) ? 0 : newVal.
c_str();
299 tag.
append(it->first.c_str());
300 tag.
append((strchr(it->second.c_str(),
'\"')) ?
"=\'" :
"=\"");
301 tag.
append(it->second.c_str());
302 tag.
append((strchr(it->second.c_str(),
'\"'))?
'\'' :
'\"');
#define SWORD_NAMESPACE_START
const char * getPart(const char *buf, int partNum=0, char partSplit= '|') const
unsigned long length() const
const char * setAttribute(const char *attribName, const char *attribValue, int partNum=-1, char partSplit= '|')
const char * getName() const
XMLTag(const char *tagString=0)
const char * toString() const
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
const StringList getAttributeNames() const
const char * c_str() const
std::list< SWBuf > StringList
SWBuf & append(const char *str, long max=-1)
void setText(const char *tagString)
const char * getAttribute(const char *attribName, int partNum=-1, char partSplit= '|') const
bool isEndTag(const char *eID=0) const
#define SWORD_NAMESPACE_END
void setSize(unsigned long len)
int getAttributePartCount(const char *attribName, char partSplit= '|') const