aboutsummaryrefslogtreecommitdiff
path: root/libxsde
diff options
context:
space:
mode:
Diffstat (limited to 'libxsde')
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type.cxx53
-rw-r--r--libxsde/xsde/cxx/hybrid/any-type.hxx28
-rw-r--r--libxsde/xsde/cxx/hybrid/parser-map.cxx59
-rw-r--r--libxsde/xsde/cxx/hybrid/parser-map.hxx52
-rw-r--r--libxsde/xsde/cxx/hybrid/serializer-map.cxx61
-rw-r--r--libxsde/xsde/cxx/hybrid/serializer-map.hxx52
-rw-r--r--libxsde/xsde/cxx/parser/map.cxx8
-rw-r--r--libxsde/xsde/cxx/parser/map.hxx1
-rw-r--r--libxsde/xsde/cxx/parser/map.ixx2
-rw-r--r--libxsde/xsde/cxx/serializer/map.cxx8
-rw-r--r--libxsde/xsde/cxx/serializer/map.hxx1
-rw-r--r--libxsde/xsde/cxx/serializer/map.ixx2
-rw-r--r--libxsde/xsde/makefile6
13 files changed, 331 insertions, 2 deletions
diff --git a/libxsde/xsde/cxx/hybrid/any-type.cxx b/libxsde/xsde/cxx/hybrid/any-type.cxx
new file mode 100644
index 0000000..b16356c
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/any-type.cxx
@@ -0,0 +1,53 @@
+// file : xsde/cxx/hybrid/any-type.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <xsde/cxx/hybrid/any-type.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ // any_type
+ //
+#ifdef XSDE_POLYMORPHIC
+ any_type::
+ ~any_type ()
+ {
+ }
+
+#ifdef XSDE_STL
+ const std::string& any_type::
+ _dynamic_type () const
+ {
+ return _static_type ();
+ }
+
+ static const std::string any_type_static_type_ =
+ "anyType http://www.w3.org/2001/XMLSchema";
+
+ const std::string& any_type::
+ _static_type ()
+ {
+ return any_type_static_type_;
+ }
+#else
+ const char* any_type::
+ _dynamic_type () const
+ {
+ return _static_type ();
+ }
+
+ const char* any_type::
+ _static_type ()
+ {
+ return "anyType http://www.w3.org/2001/XMLSchema";
+ }
+#endif
+#endif
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/any-type.hxx b/libxsde/xsde/cxx/hybrid/any-type.hxx
index db512c2..f94f007 100644
--- a/libxsde/xsde/cxx/hybrid/any-type.hxx
+++ b/libxsde/xsde/cxx/hybrid/any-type.hxx
@@ -6,6 +6,14 @@
#ifndef XSDE_CXX_HYBRID_ANY_TYPE_HXX
#define XSDE_CXX_HYBRID_ANY_TYPE_HXX
+#include <xsde/cxx/config.hxx>
+
+/*
+#ifdef XSDE_STL
+# include <string>
+#endif
+*/
+
namespace xsde
{
namespace cxx
@@ -14,6 +22,26 @@ namespace xsde
{
struct any_type
{
+ /*
+#ifdef XSDE_POLYMORPHIC
+ virtual
+ ~any_type ();
+
+#ifdef XSDE_STL
+ virtual const std::string&
+ _dynamic_type () const;
+
+ static const std::string&
+ _static_type ();
+#else
+ virtual const char*
+ _dynamic_type () const;
+
+ static const char*
+ _static_type ();
+#endif
+#endif
+ */
};
struct any_simple_type
diff --git a/libxsde/xsde/cxx/hybrid/parser-map.cxx b/libxsde/xsde/cxx/hybrid/parser-map.cxx
new file mode 100644
index 0000000..c19325c
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/parser-map.cxx
@@ -0,0 +1,59 @@
+// file : xsde/cxx/hybrid/parser-map.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <string.h> // strcmp
+
+#include <xsde/cxx/hybrid/parser-map.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ parser::parser_base* parser_map_impl::
+ find (const char* tid) const
+ {
+ // Binary search.
+ //
+ if (size_ == 0)
+ return 0;
+
+ size_t l = 0;
+ size_t h = size_ - 1;
+
+ while (l <= h)
+ {
+ size_t m = l + (h - l)/2;
+ int r = strcmp (entries_[m].type_id, tid);
+
+ if (r > 0)
+ h = m - 1;
+ else if (r < 0)
+ l = m + 1;
+ else
+ return entries_[m].parser;
+ }
+
+ return 0;
+ }
+
+ void parser_map_impl::
+ reset () const
+ {
+ if (resetting_)
+ return;
+
+ bool& r = const_cast<bool&> (resetting_);
+ r = true;
+
+ for (const entry* p = entries_; p != entries_ + size_; ++p)
+ p->parser->_reset ();
+
+ r = false;
+ }
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/parser-map.hxx b/libxsde/xsde/cxx/hybrid/parser-map.hxx
new file mode 100644
index 0000000..df84f22
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/parser-map.hxx
@@ -0,0 +1,52 @@
+// file : xsde/cxx/hybrid/parser-map.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_PARSER_MAP_HXX
+#define XSDE_CXX_HYBRID_PARSER_MAP_HXX
+
+#include <stddef.h> // size_t
+
+#include <xsde/cxx/parser/map.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ class parser_map_impl: public parser::parser_map
+ {
+ public:
+ struct entry
+ {
+ const char* type_id;
+ parser::parser_base* parser;
+ };
+
+ parser_map_impl (entry* entries, size_t size)
+ : entries_ (entries), size_ (size), resetting_ (false)
+ {
+ }
+
+ virtual parser::parser_base*
+ find (const char* type_id) const;
+
+ virtual void
+ reset () const;
+
+ private:
+ parser_map_impl (const parser_map_impl&);
+ parser_map_impl& operator= (const parser_map_impl&);
+
+ private:
+ entry* entries_;
+ size_t size_;
+ bool resetting_;
+ };
+ }
+ }
+}
+
+#endif // XSDE_CXX_HYBRID_PARSER_MAP_HXX
diff --git a/libxsde/xsde/cxx/hybrid/serializer-map.cxx b/libxsde/xsde/cxx/hybrid/serializer-map.cxx
new file mode 100644
index 0000000..7fce5fd
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/serializer-map.cxx
@@ -0,0 +1,61 @@
+// file : xsde/cxx/hybrid/serializer-map.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <string.h> // strcmp
+
+#include <xsde/cxx/hybrid/serializer-map.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ serializer::serializer_base* serializer_map_impl::
+ find (const void* v) const
+ {
+ const char* tid = static_cast<const char*> (v);
+
+ // Binary search.
+ //
+ if (size_ == 0)
+ return 0;
+
+ size_t l = 0;
+ size_t h = size_ - 1;
+
+ while (l <= h)
+ {
+ size_t m = l + (h - l)/2;
+ int r = strcmp (entries_[m].type_id, tid);
+
+ if (r > 0)
+ h = m - 1;
+ else if (r < 0)
+ l = m + 1;
+ else
+ return entries_[m].serializer;
+ }
+
+ return 0;
+ }
+
+ void serializer_map_impl::
+ reset () const
+ {
+ if (resetting_)
+ return;
+
+ bool& r = const_cast<bool&> (resetting_);
+ r = true;
+
+ for (const entry* p = entries_; p != entries_ + size_; ++p)
+ p->serializer->_reset ();
+
+ r = false;
+ }
+ }
+ }
+}
diff --git a/libxsde/xsde/cxx/hybrid/serializer-map.hxx b/libxsde/xsde/cxx/hybrid/serializer-map.hxx
new file mode 100644
index 0000000..5e3fb1a
--- /dev/null
+++ b/libxsde/xsde/cxx/hybrid/serializer-map.hxx
@@ -0,0 +1,52 @@
+// file : xsde/cxx/hybrid/serializer-map.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef XSDE_CXX_HYBRID_SERIALIZER_MAP_HXX
+#define XSDE_CXX_HYBRID_SERIALIZER_MAP_HXX
+
+#include <stddef.h> // size_t
+
+#include <xsde/cxx/serializer/map.hxx>
+
+namespace xsde
+{
+ namespace cxx
+ {
+ namespace hybrid
+ {
+ class serializer_map_impl: public serializer::serializer_map
+ {
+ public:
+ struct entry
+ {
+ const char* type_id;
+ serializer::serializer_base* serializer;
+ };
+
+ serializer_map_impl (entry* entries, size_t size)
+ : entries_ (entries), size_ (size), resetting_ (true)
+ {
+ }
+
+ virtual serializer::serializer_base*
+ find (const void* type_id) const;
+
+ virtual void
+ reset () const;
+
+ private:
+ serializer_map_impl (const serializer_map_impl&);
+ serializer_map_impl& operator= (const serializer_map_impl&);
+
+ private:
+ entry* entries_;
+ size_t size_;
+ bool resetting_;
+ };
+ }
+ }
+}
+
+#endif // XSDE_CXX_HYBRID_SERIALIZER_MAP_HXX
diff --git a/libxsde/xsde/cxx/parser/map.cxx b/libxsde/xsde/cxx/parser/map.cxx
index b21c41e..1382c8d 100644
--- a/libxsde/xsde/cxx/parser/map.cxx
+++ b/libxsde/xsde/cxx/parser/map.cxx
@@ -23,12 +23,20 @@ namespace xsde
void parser_map_impl::
reset () const
{
+ if (resetting_)
+ return;
+
+ bool& r = const_cast<bool&> (resetting_);
+ r = true;
+
for (hashmap::const_iterator i (map_.begin ()), e (map_.end ());
i != e; ++i)
{
parser_base* p = *static_cast<parser_base* const*> (*i);
p->_reset ();
}
+
+ r = false;
}
}
}
diff --git a/libxsde/xsde/cxx/parser/map.hxx b/libxsde/xsde/cxx/parser/map.hxx
index 400de27..0a5c99c 100644
--- a/libxsde/xsde/cxx/parser/map.hxx
+++ b/libxsde/xsde/cxx/parser/map.hxx
@@ -77,6 +77,7 @@ namespace xsde
private:
hashmap map_;
+ bool resetting_;
};
}
}
diff --git a/libxsde/xsde/cxx/parser/map.ixx b/libxsde/xsde/cxx/parser/map.ixx
index 3a1f931..0f5e477 100644
--- a/libxsde/xsde/cxx/parser/map.ixx
+++ b/libxsde/xsde/cxx/parser/map.ixx
@@ -19,7 +19,7 @@ namespace xsde
inline parser_map_impl::
parser_map_impl (size_t buckets)
- : map_ (buckets, sizeof (parser_base*))
+ : map_ (buckets, sizeof (parser_base*)), resetting_ (false)
{
}
diff --git a/libxsde/xsde/cxx/serializer/map.cxx b/libxsde/xsde/cxx/serializer/map.cxx
index 1ace4ac..f3c88f6 100644
--- a/libxsde/xsde/cxx/serializer/map.cxx
+++ b/libxsde/xsde/cxx/serializer/map.cxx
@@ -23,12 +23,20 @@ namespace xsde
void serializer_map_impl::
reset () const
{
+ if (resetting_)
+ return;
+
+ bool& r = const_cast<bool&> (resetting_);
+ r = true;
+
for (hashmap::const_iterator i (map_.begin ()), e (map_.end ());
i != e; ++i)
{
serializer_base* s = *static_cast<serializer_base* const*> (*i);
s->_reset ();
}
+
+ r = false;
}
}
}
diff --git a/libxsde/xsde/cxx/serializer/map.hxx b/libxsde/xsde/cxx/serializer/map.hxx
index 2cfc755..1fe4eb0 100644
--- a/libxsde/xsde/cxx/serializer/map.hxx
+++ b/libxsde/xsde/cxx/serializer/map.hxx
@@ -86,6 +86,7 @@ namespace xsde
private:
hashmap map_;
+ bool resetting_;
};
}
}
diff --git a/libxsde/xsde/cxx/serializer/map.ixx b/libxsde/xsde/cxx/serializer/map.ixx
index 64eb19a..e1c2a28 100644
--- a/libxsde/xsde/cxx/serializer/map.ixx
+++ b/libxsde/xsde/cxx/serializer/map.ixx
@@ -19,7 +19,7 @@ namespace xsde
inline serializer_map_impl::
serializer_map_impl (size_t buckets)
- : map_ (buckets, sizeof (serializer_base*))
+ : map_ (buckets, sizeof (serializer_base*)), resetting_ (false)
{
}
diff --git a/libxsde/xsde/makefile b/libxsde/xsde/makefile
index f7d17ed..64368d0 100644
--- a/libxsde/xsde/makefile
+++ b/libxsde/xsde/makefile
@@ -45,6 +45,12 @@ endif
##
cxx_tun += cxx/hybrid/sequence.cxx
+ifeq ($(xsde_polymorphic),y)
+cxx_tun += \
+cxx/hybrid/parser-map.cxx \
+cxx/hybrid/serializer-map.cxx
+endif
+
ifeq ($(xsde_cdr),y)
cxx_tun += \
cxx/hybrid/cdr/exceptions.cxx \