extendions and corrections

master
Marc Wäckerlin 16 years ago
parent e48b91683e
commit 98334b4565
  1. 6
      install-64-and-32-bit-linux.sh
  2. 9
      src/xml-cxx/xml.hxx
  3. 14
      src/xml.cxx

@ -1,19 +1,19 @@
./bootstrap.sh && \ ./bootstrap.sh && \
LDFLAGS="-L/usr/lib32 -m32" CXXFLAGS="-m32" ./configure \ LDFLAGS="-L/usr/lib32 -m32" CXXFLAGS="-m32 $DBG" ./configure \
--libdir=/usr/local/lib32 \ --libdir=/usr/local/lib32 \
--build=x86_64 \ --build=x86_64 \
--host=i386 && \ --host=i386 && \
make && \ make && \
sudo make install && \ sudo make install && \
make clean && \ make clean && \
./configure \ CXXFLAGS="$DBG" ./configure \
--prefix=/opt/local/i586-mingw32msvc \ --prefix=/opt/local/i586-mingw32msvc \
--build=x86_64 \ --build=x86_64 \
--host=i586-mingw32msvc && \ --host=i586-mingw32msvc && \
make && \ make && \
sudo make install && \ sudo make install && \
make clean && \ make clean && \
./configure && \ CXXFLAGS="$DBG" ./configure && \
make check && \ make check && \
sudo make install sudo make install

@ -163,6 +163,13 @@ namespace xml {
Node* _child; Node* _child;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
class attribute_not_available: public exception {
public:
attribute_not_available(const Node& t, const std::string& attr) throw():
exception("attribute \""+attr+"\" not set", t) {
}
};
//----------------------------------------------------------------------------
class stream_error: public exception { class stream_error: public exception {
public: public:
stream_error(const std::string& reason, const Node& t, stream_error(const std::string& reason, const Node& t,
@ -324,6 +331,8 @@ namespace xml {
Node& attr(const std::string& name, bool mandatory) throw(); Node& attr(const std::string& name, bool mandatory) throw();
std::string attr(const std::string& name) const throw(); std::string attr(const std::string& name) const throw();
std::string& attr(const std::string& name) throw(); std::string& attr(const std::string& name) throw();
const Attributes::Value attribute(const std::string& name)
const throw(attribute_not_available);
List list(const std::string& name) const throw(); List list(const std::string& name) const throw();
bool operator()(const std::string& child) const throw(); bool operator()(const std::string& child) const throw();
Node& operator<<(const Node& o) throw(cannot_have_children); Node& operator<<(const Node& o) throw(cannot_have_children);

@ -184,9 +184,13 @@ namespace xml {
const throw() { const throw() {
List l; List l;
for (std::string::size_type it(0), pos(0); for (std::string::size_type it(0), pos(0);
(pos=second.find_first_of(separators, it)), it!=std::string::npos; it!=std::string::npos &&
((pos=second.find_first_of(separators, it)), true);
it=pos!=std::string::npos?++pos:std::string::npos) it=pos!=std::string::npos?++pos:std::string::npos)
l.push_back(std::string(second.begin()+it, second.begin()+pos)); if (pos==std::string::npos)
l.push_back(second.substr(it));
else
l.push_back(second.substr(it, pos-it));
return l; return l;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -312,6 +316,12 @@ namespace xml {
std::string& Node::attr(const std::string& name) throw() { std::string& Node::attr(const std::string& name) throw() {
return _attributes[name]; return _attributes[name];
} }
const Attributes::Value Node::attribute(const std::string& name)
const throw(attribute_not_available) {
Attributes::const_iterator it(_attributes.find(name));
if (it!=_attributes.end()) return *it;
throw attribute_not_available(*this, name);
}
Node::List Node::list(const std::string& name) const throw() { Node::List Node::list(const std::string& name) const throw() {
List res; List res;
for (Contents::const_iterator it(_contents.begin()); for (Contents::const_iterator it(_contents.begin());

Loading…
Cancel
Save