summaryrefslogtreecommitdiff
path: root/ACE
diff options
context:
space:
mode:
Diffstat (limited to 'ACE')
-rw-r--r--ACE/ace/CDR_Base.cpp20
-rw-r--r--ACE/ace/CDR_Base.h2
-rw-r--r--ACE/ace/CDR_Size.h3
-rw-r--r--ACE/ace/CDR_Size.inl14
-rw-r--r--ACE/ace/CDR_Stream.h8
-rw-r--r--ACE/ace/CDR_Stream.inl62
-rw-r--r--ACE/bin/.gitignore1
-rw-r--r--ACE/tests/CDR_Test.cpp11
8 files changed, 121 insertions, 0 deletions
diff --git a/ACE/ace/CDR_Base.cpp b/ACE/ace/CDR_Base.cpp
index ca23038383a..505f4cf79e6 100644
--- a/ACE/ace/CDR_Base.cpp
+++ b/ACE/ace/CDR_Base.cpp
@@ -976,6 +976,20 @@ ACE_CDR::Fixed ACE_CDR::Fixed::from_string (const char *str)
return f;
}
+ACE_CDR::Fixed ACE_CDR::Fixed::from_octets (const Octet *array, int len)
+{
+ Fixed f;
+ ACE_OS::memcpy (f.value_ + 16 - len, array, len);
+ ACE_OS::memset (f.value_, 0, 16 - len);
+ f.scale_ = 0;
+
+ f.digits_ = len * 2 - 1;
+ if (len > 1 && (array[0] >> 4) == 0)
+ --f.digits_;
+
+ return f;
+}
+
ACE_CDR::Fixed::operator LongLong () const
{
LongLong val (0);
@@ -1115,6 +1129,12 @@ bool ACE_CDR::Fixed::to_string (char *buffer, size_t buffer_size) const
return true;
}
+const ACE_CDR::Octet *ACE_CDR::Fixed::to_octets (int &n) const
+{
+ n = (this->digits_ + 2) / 2;
+ return 16 - n + reinterpret_cast<const Octet *> (this->value_);
+}
+
ACE_CDR::Fixed::ConstIterator ACE_CDR::Fixed::pre_add (const ACE_CDR::Fixed &f)
{
ConstIterator rhs_iter = f.begin ();
diff --git a/ACE/ace/CDR_Base.h b/ACE/ace/CDR_Base.h
index 36d35a8c9dd..3afa0615aaa 100644
--- a/ACE/ace/CDR_Base.h
+++ b/ACE/ace/CDR_Base.h
@@ -374,6 +374,7 @@ public:
static Fixed from_integer (ULongLong val);
static Fixed from_floating (LongDouble val);
static Fixed from_string (const char *str);
+ static Fixed from_octets (const Octet *array, int len);
operator LongLong () const;
operator LongDouble () const;
@@ -382,6 +383,7 @@ public:
Fixed truncate (UShort scale) const;
bool to_string (char *buffer, size_t buffer_size) const;
+ const Octet *to_octets (int &n) const;
Fixed &operator+= (const Fixed &rhs);
Fixed &operator-= (const Fixed &rhs);
diff --git a/ACE/ace/CDR_Size.h b/ACE/ace/CDR_Size.h
index ca85b674035..ad229bca388 100644
--- a/ACE/ace/CDR_Size.h
+++ b/ACE/ace/CDR_Size.h
@@ -68,6 +68,7 @@ public:
ACE_CDR::Boolean write_float (ACE_CDR::Float x);
ACE_CDR::Boolean write_double (const ACE_CDR::Double &x);
ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x);
+ ACE_CDR::Boolean write_fixed (const ACE_CDR::Fixed &x);
/// For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_string (const ACE_CDR::Char *x);
@@ -201,6 +202,8 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
ACE_CDR::Float x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
ACE_CDR::Double x);
+extern ACE_Export ACE_CDR::Boolean operator<< (ACE_SizeCDR &ss,
+ const ACE_CDR::Fixed &x);
// CDR size-calculating output operator from helper classes
diff --git a/ACE/ace/CDR_Size.inl b/ACE/ace/CDR_Size.inl
index fe04ea99955..9b83b6f72e0 100644
--- a/ACE/ace/CDR_Size.inl
+++ b/ACE/ace/CDR_Size.inl
@@ -113,6 +113,13 @@ ACE_SizeCDR::write_longdouble (const ACE_CDR::LongDouble &x)
}
ACE_INLINE ACE_CDR::Boolean
+ACE_SizeCDR::write_fixed (const ACE_CDR::Fixed &x)
+{
+ return this->write_array (&x, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN,
+ (x.fixed_digits () + 2) / 2);
+}
+
+ACE_INLINE ACE_CDR::Boolean
ACE_SizeCDR::write_string (const ACE_CDR::Char *x)
{
if (x != 0)
@@ -345,6 +352,13 @@ operator<< (ACE_SizeCDR &ss, ACE_CDR::Double x)
}
ACE_INLINE ACE_CDR::Boolean
+operator<< (ACE_SizeCDR &ss, const ACE_CDR::Fixed &x)
+{
+ ss.write_fixed (x);
+ return (ACE_CDR::Boolean) ss.good_bit ();
+}
+
+ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_SizeCDR &ss, const ACE_CDR::Char *x)
{
ss.write_string (x);
diff --git a/ACE/ace/CDR_Stream.h b/ACE/ace/CDR_Stream.h
index 7556a42a0dc..8197b0f4be2 100644
--- a/ACE/ace/CDR_Stream.h
+++ b/ACE/ace/CDR_Stream.h
@@ -240,6 +240,7 @@ public:
ACE_CDR::Boolean write_float (ACE_CDR::Float x);
ACE_CDR::Boolean write_double (const ACE_CDR::Double &x);
ACE_CDR::Boolean write_longdouble (const ACE_CDR::LongDouble &x);
+ ACE_CDR::Boolean write_fixed (const ACE_CDR::Fixed &x);
/// For string we offer methods that accept a precomputed length.
ACE_CDR::Boolean write_string (const ACE_CDR::Char *x);
@@ -368,6 +369,7 @@ public:
ACE_CDR::Boolean append_float (ACE_InputCDR &);
ACE_CDR::Boolean append_double (ACE_InputCDR &);
ACE_CDR::Boolean append_longdouble (ACE_InputCDR &);
+ ACE_CDR::Boolean append_fixed (ACE_InputCDR &);
ACE_CDR::Boolean append_wstring (ACE_InputCDR &);
ACE_CDR::Boolean append_string (ACE_InputCDR &);
@@ -811,6 +813,7 @@ public:
ACE_CDR::Boolean read_float (ACE_CDR::Float &x);
ACE_CDR::Boolean read_double (ACE_CDR::Double &x);
ACE_CDR::Boolean read_longdouble (ACE_CDR::LongDouble &x);
+ ACE_CDR::Boolean read_fixed (ACE_CDR::Fixed &x);
ACE_CDR::Boolean read_string (ACE_CDR::Char *&x);
ACE_CDR::Boolean read_string (ACE_CString &x);
@@ -868,6 +871,7 @@ public:
ACE_CDR::Boolean skip_float (void);
ACE_CDR::Boolean skip_double (void);
ACE_CDR::Boolean skip_longdouble (void);
+ ACE_CDR::Boolean skip_fixed (void);
//@}
/**
@@ -1319,6 +1323,8 @@ extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
ACE_CDR::Float x);
extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
ACE_CDR::Double x);
+extern ACE_Export ACE_CDR::Boolean operator<< (ACE_OutputCDR &os,
+ const ACE_CDR::Fixed &x);
// CDR output operator from helper classes
@@ -1362,6 +1368,8 @@ extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CDR::Float &x);
extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
ACE_CDR::Double &x);
+extern ACE_Export ACE_CDR::Boolean operator>> (ACE_InputCDR &is,
+ ACE_CDR::Fixed &x);
// CDR input operator from helper classes
diff --git a/ACE/ace/CDR_Stream.inl b/ACE/ace/CDR_Stream.inl
index 6b79c4c6bc9..fdc741146f6 100644
--- a/ACE/ace/CDR_Stream.inl
+++ b/ACE/ace/CDR_Stream.inl
@@ -268,6 +268,14 @@ ACE_OutputCDR::write_longdouble (const ACE_CDR::LongDouble &x)
}
ACE_INLINE ACE_CDR::Boolean
+ACE_OutputCDR::write_fixed (const ACE_CDR::Fixed &x)
+{
+ int n;
+ const ACE_CDR::Octet *arr = x.to_octets (n);
+ return this->write_array (arr, ACE_CDR::OCTET_SIZE, ACE_CDR::OCTET_ALIGN, n);
+}
+
+ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::write_string (const ACE_CDR::Char *x)
{
if (x)
@@ -709,6 +717,25 @@ ACE_InputCDR::read_longdouble (ACE_CDR::LongDouble &x)
return this->read_16 (&x);
}
+ACE_INLINE ACE_CDR::Boolean
+ACE_InputCDR::read_fixed (ACE_CDR::Fixed &x)
+{
+ ACE_CDR::Octet a[16];
+ for (int i = 0; i < 16; ++i)
+ {
+ if (!this->read_1 (a + i))
+ return false;
+ const unsigned low = a[i] & 0xf;
+ if (low == 0xc || low == 0xd)
+ {
+ x = ACE_CDR::Fixed::from_octets (a, i + 1);
+ return true;
+ }
+ }
+
+ return false;
+}
+
ACE_INLINE size_t
ACE_InputCDR::length (void) const
{
@@ -1016,6 +1043,21 @@ ACE_InputCDR::skip_longdouble (void)
return this->read_16 (&x);
}
+ACE_INLINE ACE_CDR::Boolean
+ACE_InputCDR::skip_fixed (void)
+{
+ for (int i = 0; i < 16; ++i)
+ {
+ ACE_CDR::Octet x;
+ if (!this->read_1 (&x))
+ return false;
+ const unsigned low = x & 0xf;
+ if (low == 0xc || low == 0xd)
+ return true;
+ }
+ return false;
+}
+
ACE_INLINE char*
ACE_InputCDR::end (void)
{
@@ -1157,6 +1199,13 @@ operator<< (ACE_OutputCDR &os, ACE_CDR::Double x)
}
ACE_INLINE ACE_CDR::Boolean
+operator<< (ACE_OutputCDR &os, const ACE_CDR::Fixed &x)
+{
+ os.write_fixed (x);
+ return (ACE_CDR::Boolean) os.good_bit ();
+}
+
+ACE_INLINE ACE_CDR::Boolean
operator<< (ACE_OutputCDR &os, const ACE_CDR::Char *x)
{
os.write_string (x);
@@ -1292,6 +1341,12 @@ operator>> (ACE_InputCDR &is, ACE_CDR::Double &x)
}
ACE_INLINE ACE_CDR::Boolean
+operator>> (ACE_InputCDR &is, ACE_CDR::Fixed &x)
+{
+ return is.read_fixed (x) && is.good_bit ();
+}
+
+ACE_INLINE ACE_CDR::Boolean
operator>> (ACE_InputCDR &is, ACE_CDR::Char *&x)
{
return is.read_string (x) && is.good_bit ();
@@ -1447,6 +1502,13 @@ ACE_OutputCDR::append_longdouble (ACE_InputCDR &stream)
}
ACE_INLINE ACE_CDR::Boolean
+ACE_OutputCDR::append_fixed (ACE_InputCDR &stream)
+{
+ ACE_CDR::Fixed x;
+ return stream.read_fixed (x) ? this->write_fixed (x) : false;
+}
+
+ACE_INLINE ACE_CDR::Boolean
ACE_OutputCDR::append_string (ACE_InputCDR &stream)
{
ACE_CDR::Char *x = 0;
diff --git a/ACE/bin/.gitignore b/ACE/bin/.gitignore
index 1ac82dfd0ba..01ce0a68189 100644
--- a/ACE/bin/.gitignore
+++ b/ACE/bin/.gitignore
@@ -6,4 +6,5 @@
/tao_logWalker
/tao_nsadd
/tao_nsdel
+/tao_nsgroup
/tao_nslist
diff --git a/ACE/tests/CDR_Test.cpp b/ACE/tests/CDR_Test.cpp
index 0edc6ef47ff..cdb099b4c75 100644
--- a/ACE/tests/CDR_Test.cpp
+++ b/ACE/tests/CDR_Test.cpp
@@ -109,6 +109,7 @@ short_stream (void)
ACE_CDR::ULong ul = 65800UL;
ACE_CDR::Float f = 1.23f;
ACE_CDR::Double d = 123.456789;
+ ACE_CDR::Fixed fx = ACE_CDR::Fixed::from_string ("8158901571290874");
// Arrays for output
ACE_CDR::Short s_array[3] = { -1, 0, 1 };
@@ -129,6 +130,7 @@ short_stream (void)
os << ul;
os << f;
os << d;
+ os << fx;
os.write_short_array (s_array, 3);
os.write_long_array (l_array, 3);
os.write_float_array (f_array, 3);
@@ -146,6 +148,7 @@ short_stream (void)
ss << ul;
ss << f;
ss << d;
+ ss << fx;
ss.write_short_array (s_array, 3);
ss.write_long_array (l_array, 3);
ss.write_float_array (f_array, 3);
@@ -198,6 +201,7 @@ short_stream (void)
ACE_CDR::ULong ul1 = 0UL;
ACE_CDR::Float f1 = 0.0f;
ACE_CDR::Double d1 = 0.0;
+ ACE_CDR::Fixed fx1 = ACE_CDR::Fixed::from_string ("0");
// Arrays for input
ACE_CDR::Short s_array1[3];
@@ -224,6 +228,7 @@ short_stream (void)
is >> ul1;
is >> f1;
is >> d1;
+ is >> fx1;
is.read_short_array (s_array1, 3);
is.read_long_array (l_array1, 3);
is.read_float_array (f_array1, 3);
@@ -290,6 +295,12 @@ short_stream (void)
ACE_TEXT ("double transfer error")),
1);
+ if (fx1 != fx)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("fixed transfer error")),
+ 1);
+
for (i = 0 ; i < 3; i++)
if (s_array1[i] != s_array[i])
ACE_ERROR_RETURN ((LM_ERROR,