summaryrefslogtreecommitdiff
path: root/TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr.hpp')
-rw-r--r--TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr.hpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr.hpp b/TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr.hpp
new file mode 100644
index 00000000000..fd1e9aac05b
--- /dev/null
+++ b/TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr.hpp
@@ -0,0 +1,56 @@
+#ifndef guard_unbounded_sequence_cdr
+#define guard_unbounded_sequence_cdr
+/**
+ * @file
+ *
+ * @brief Extract the sequence
+ *
+ * $Id$
+ *
+ * @author Carlos O'Ryan
+ * @author Johnny Willemsen
+ */
+
+#include "tao/Basic_Types.h"
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+namespace TAO {
+ namespace details {
+ template <typename stream, typename sequence>
+ bool extract_unbounded_sequence(stream & strm, sequence & target) {
+ ::CORBA::ULong new_length;
+ if (!(strm >> new_length)) {
+ return false;
+ }
+ if (new_length > strm.length()) {
+ return false;
+ }
+ sequence tmp(new_length);
+ tmp.length(new_length);
+ typename sequence::value_type * buffer = tmp.get_buffer();
+ for(CORBA::ULong i = 0; i < new_length; ++i) {
+ if (!(strm >> buffer[i])) {
+ return false;
+ }
+ }
+ tmp.swap(target);
+ return true;
+ }
+
+ template <typename stream, typename sequence>
+ bool insert_unbounded_sequence(stream & strm, const sequence & source) {
+ const CORBA::ULong length = source.length ();
+ if (!(strm << length)) {
+ return false;
+ }
+ for(CORBA::ULong i = 0; i < length; ++i) {
+ if (!(strm << source[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+}
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+#endif /* guard_unbounded_sequence_cdr */