Permalink
Browse files

Eli's XML attribute patch.

git-svn-id: svn://okws.org/okws2/devel/3.1@5576 7d287422-6eea-da11-b677-00123f2a783a
  • Loading branch information...
1 parent eebca01 commit 1007a8b958a3da476b1d6a09a09836c490895239 max committed Jan 21, 2011
Showing with 28 additions and 7 deletions.
  1. +2 −2 configure.in
  2. +4 −0 libokxml/okxmldata.h
  3. +2 −1 libokxml/okxmlobj.h
  4. +7 −0 libokxml/xmldata.C
  5. +11 −2 libokxml/xmlobj.C
  6. +1 −1 libpub/okws_sfs.h
  7. +1 −1 okd/okldch.T
View
4 configure.in
@@ -4,10 +4,10 @@ dnl Process this file with autoconf to produce a configure script.
dnl
AC_INIT(config.h.in)
-AM_INIT_AUTOMAKE(okws, 3.1.4.5)
+AM_INIT_AUTOMAKE(okws, 3.1.4.6)
AM_CONFIG_HEADER(config.h)
-SFS_INIT_LDVERSION(33)
+SFS_INIT_LDVERSION(34)
AC_CONFIG_MACRO_DIR([m4])
View
4 libokxml/okxmldata.h
@@ -804,6 +804,7 @@ bool has_non_ws (const char *buf, int len);
class xml_attributes_t {
public:
xml_attributes_t (const char **atts);
+ xml_attributes_t (const vec<str>& atts);
scalar_obj_t operator[] (const str &k) const { return lookup (k); }
scalar_obj_t lookup (const str &k) const;
bool lookup (const str &k, scalar_obj_t *so) const;
@@ -852,6 +853,9 @@ class xml_generic_t : public xml_element_t {
xml_generic_t (const char *n = NULL, const char **atts = NULL) :
xml_element_t (), _class (n), _atts (atts) {}
+ xml_generic_t (const char *n, const vec<str>& atts) :
+ xml_element_t (), _class (n), _atts (atts) {}
+
bool add (ptr<xml_element_t> e);
const ptr<vec<ptr<xml_generic_t> > > *lookup (const str &k) const
View
3 libokxml/okxmlobj.h
@@ -28,6 +28,7 @@
#include "okxmldata.h"
#include "pub3expr.h"
#include "pub3obj.h"
+#include <stdarg.h>
//
// What's this?
@@ -270,7 +271,7 @@ class xml_gobj_t : public xml_gobj_base_t {
xml_gobj_t () : _obj (xml_generic_t::alloc_null ()) {}
xml_gobj_t operator[] (size_t s) ;
- xml_gobj_t operator() (const str &k) ;
+ xml_gobj_t operator() (const str &k, int n_atts = 0, ...) ;
template<class T>
xml_gobj_t &operator=(T s) { set (s); return (*this); }
View
7 libokxml/xmldata.C
@@ -885,6 +885,13 @@ xml_attributes_t::xml_attributes_t (const char **atts)
}
}
+xml_attributes_t::xml_attributes_t (const vec<str>& atts)
+{
+ for (size_t i = 0; i < atts.size(); i += 2) {
+ _t.insert (atts[i], scalar_obj_t (atts[i + 1]));
+ }
+}
+
scalar_obj_t _null_so;
scalar_obj_t
View
13 libokxml/xmlobj.C
@@ -221,13 +221,22 @@ xml_gobj_t::operator[] (size_t i)
}
xml_gobj_t
-xml_gobj_t::operator() (const str &k)
+xml_gobj_t::operator() (const str &k, int n_atts, ...)
{
+ vec<str> attrs;
+ va_list al;
+ va_start(al, n_atts);
+ for (int i = 0; i < n_atts; ++i) {
+ const char* s = va_arg(al, char*);
+ attrs.push_back(s);
+ }
+ va_end(al);
+
const ptr<vec<ptr<xml_generic_t> > > *v = obj ()->lookup (k);
if (v) {
return xml_gobj_t (NULL, *v);
} else {
- ptr<xml_generic_t> g = New refcounted<xml_generic_t> (k);
+ ptr<xml_generic_t> g = New refcounted<xml_generic_t> (k, attrs);
obj ()->add (g);
return xml_gobj_t (g);
}
View
2 libpub/okws_sfs.h
@@ -52,7 +52,7 @@
#define OKWS_VERSION_MAJOR 3
#define OKWS_VERSION_MINOR 1
#define OKWS_VERSION_PATCHLEVEL 4
-#define OKWS_VERSION_PRE 105
+#define OKWS_VERSION_PRE 106
#define OKWS_AT_VERSION(Maj,Min,Pat,Pre) \
View
2 okd/okldch.T
@@ -517,7 +517,7 @@ void
okld_ch_t::post_fork_cb ()
{
// close any ports that we were instructed to close earlier
- direct_ports ().do_close_ports (_servpath);
+ direct_ports ().do_close_ports (str_id ());
// after fork, we need to set our PID
_pid = getpid ();

0 comments on commit 1007a8b

Please sign in to comment.