aboutsummaryrefslogtreecommitdiff
path: root/libxsde
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-03-11 17:32:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-03-11 17:32:01 +0200
commit0bfda486167432a9da8eec62b4578a22592a9275 (patch)
tree968d622d3918c9ac969de8b9c1e97e67b6cbee8b /libxsde
parentf8bb2faef4b272ed150eb3ca4cedaa79da410694 (diff)
Add generation of detach functions
New option: --generate-detach. Also added detach/attach functionality to var_seq, non-STL str_seq, and string_base.
Diffstat (limited to 'libxsde')
-rw-r--r--libxsde/xsde/cxx/hybrid/base.hxx1
-rw-r--r--libxsde/xsde/cxx/hybrid/sequence.hxx12
-rw-r--r--libxsde/xsde/cxx/hybrid/sequence.ixx17
-rw-r--r--libxsde/xsde/cxx/string-sequence.hxx5
-rw-r--r--libxsde/xsde/cxx/string-sequence.ixx7
5 files changed, 42 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/hybrid/base.hxx b/libxsde/xsde/cxx/hybrid/base.hxx
index 75753bc..ba5090d 100644
--- a/libxsde/xsde/cxx/hybrid/base.hxx
+++ b/libxsde/xsde/cxx/hybrid/base.hxx
@@ -354,6 +354,7 @@ namespace xsde
const char* base_value () const {return x_;}
char* base_value () {return x_;}
void base_value (char* x) {delete[] x_; x_ = x;}
+ char* base_value_detach () {char* r = x_; x_ = 0; return r;}
operator const char* () const {return x_;}
operator char* () {return x_;}
diff --git a/libxsde/xsde/cxx/hybrid/sequence.hxx b/libxsde/xsde/cxx/hybrid/sequence.hxx
index 6d8f33b..b0cdba2 100644
--- a/libxsde/xsde/cxx/hybrid/sequence.hxx
+++ b/libxsde/xsde/cxx/hybrid/sequence.hxx
@@ -792,6 +792,18 @@ namespace xsde
insert (iterator, T*);
#endif
+ // Detach an object from the sequence at a given position.
+ // The object pointer at this position in the sequence is
+ // set to 0.
+ //
+ T*
+ detach (iterator);
+
+ // Attach an object to the sequence at a given position.
+ //
+ void
+ attach (iterator, T*);
+
#ifndef XSDE_EXCEPTIONS
error
#else
diff --git a/libxsde/xsde/cxx/hybrid/sequence.ixx b/libxsde/xsde/cxx/hybrid/sequence.ixx
index 11bc13d..a015e31 100644
--- a/libxsde/xsde/cxx/hybrid/sequence.ixx
+++ b/libxsde/xsde/cxx/hybrid/sequence.ixx
@@ -569,6 +569,23 @@ namespace xsde
return i;
}
+ template <typename T>
+ inline T* var_seq<T>::
+ detach (iterator i)
+ {
+ T* r = *i.i_;
+ *i.i_ = 0;
+ return r;
+ }
+
+ template <typename T>
+ inline void var_seq<T>::
+ attach (iterator i, T* x)
+ {
+ delete *i.i_;
+ *i.i_ = x;
+ }
+
#ifdef XSDE_EXCEPTIONS
template <typename T>
inline void var_seq<T>::
diff --git a/libxsde/xsde/cxx/string-sequence.hxx b/libxsde/xsde/cxx/string-sequence.hxx
index 50c0025..1278cfc 100644
--- a/libxsde/xsde/cxx/string-sequence.hxx
+++ b/libxsde/xsde/cxx/string-sequence.hxx
@@ -109,6 +109,11 @@ namespace xsde
char*
detach (iterator);
+ // Attach a string to the sequence at a given position.
+ //
+ void
+ attach (iterator, char*);
+
#ifndef XSDE_EXCEPTIONS
error
#else
diff --git a/libxsde/xsde/cxx/string-sequence.ixx b/libxsde/xsde/cxx/string-sequence.ixx
index 58878b7..2a895f8 100644
--- a/libxsde/xsde/cxx/string-sequence.ixx
+++ b/libxsde/xsde/cxx/string-sequence.ixx
@@ -222,6 +222,13 @@ namespace xsde
return r;
}
+ inline void string_sequence::
+ attach (iterator p, char* x)
+ {
+ delete[] *p;
+ *p = x;
+ }
+
//
//
inline bool