[sword-cvs] sword/include utilxml.h,NONE,1.1 swbuf.h,1.12,1.13
sword@www.crosswire.org
sword@www.crosswire.org
Sun, 25 May 2003 21:32:47 -0700
Update of /usr/local/cvsroot/sword/include
In directory www:/tmp/cvs-serv8807/include
Modified Files:
swbuf.h
Added Files:
utilxml.h
Log Message:
Added utilfuns/utilxml.cpp and test/xmltest which
include basic xml utility classes
Added comparison operators to SWBuf so it plays
nicely with stl containers
--- NEW FILE: utilxml.h ---
/******************************************************************************
* utilxml.h - definition of class that deal with xml constructs
*
* $Id: utilxml.h,v 1.1 2003/05/26 04:32:45 scribe Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
*/
#ifndef UTILXML_H
#define UTILXML_H
#include <defs.h>
#include <swbuf.h>
#include <list>
#include <map>
SWORD_NAMESPACE_START
typedef std::map<SWBuf, SWBuf> MapStringPair;
typedef std::list<SWBuf> ListString;
class SWDLLEXPORT XMLTag {
private:
mutable char *buf;
char *name;
mutable bool parsed;
mutable bool empty;
mutable bool endTag;
mutable MapStringPair attributes;
void parse() const;
public:
XMLTag(const char *tagString);
~XMLTag();
inline const char *getName() const { return name; }
inline bool isEmpty() const {
if (!parsed)
parse();
return empty;
}
inline bool isEndTag() const { return endTag; }
const ListString getAttributeNames() const;
const char *getAttribute(const char *attribName) const;
const char *setAttribute(const char *attribName, const char *attribValue) {
if (!parsed)
parse();
attributes[attribName] = attribValue;
}
const char *toString() const;
inline operator const char *() const { return toString(); }
};
SWORD_NAMESPACE_END
#endif
Index: swbuf.h
===================================================================
RCS file: /usr/local/cvsroot/sword/include/swbuf.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** swbuf.h 31 Mar 2003 00:14:14 -0000 1.12
--- swbuf.h 26 May 2003 04:32:45 -0000 1.13
***************
*** 25,28 ****
--- 25,29 ----
#include <defs.h>
#include <stdlib.h>
+ #include <string.h>
SWORD_NAMESPACE_START
***************
*** 177,180 ****
--- 178,196 ----
}
inline SWBuf operator +(char ch) const { return (*this) + SWBuf(ch); }
+
+ int compare(const SWBuf &other) const { return strncmp(c_str(), other.c_str(), (length() < other.length()) ? length() : other.length()); }
+ inline bool operator ==(const SWBuf &other) const { return !compare(other); }
+ inline bool operator !=(const SWBuf &other) const { return compare(other); }
+ inline bool operator > (const SWBuf &other) const { return compare(other) > 0; }
+ inline bool operator < (const SWBuf &other) const { return compare(other) < 0; }
+ inline bool operator <=(const SWBuf &other) const { return compare(other) <= 0; }
+ inline bool operator >=(const SWBuf &other) const { return compare(other) >= 0; }
+
+ inline bool operator ==(const char *other) const { return !compare(other); }
+ inline bool operator !=(const char *other) const { return compare(other); }
+ inline bool operator > (const char *other) const { return compare(other) > 0; }
+ inline bool operator < (const char *other) const { return compare(other) < 0; }
+ inline bool operator <=(const char *other) const { return compare(other) <= 0; }
+ inline bool operator >=(const char *other) const { return compare(other) >= 0; }
};