summaryrefslogtreecommitdiff
path: root/src/os/object/xdrstream.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/object/xdrstream.cc')
-rw-r--r--src/os/object/xdrstream.cc33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/os/object/xdrstream.cc b/src/os/object/xdrstream.cc
index eb5ca87..d7a5ace 100644
--- a/src/os/object/xdrstream.cc
+++ b/src/os/object/xdrstream.cc
@@ -69,6 +69,9 @@ XDRStream & XDRStream::operator<<(int64_t number)
}
XDRStream & XDRStream::operator<<(char const *data){
+ if (!is_fixed_length) {
+ *this << next_array_len;
+ }
uint32_t i;
for (i = 0; i < next_array_len; i++) {
put(data[i]);
@@ -79,6 +82,21 @@ XDRStream & XDRStream::operator<<(char const *data){
return *this;
}
+template<int N>
+XDRStream & XDRStream::operator<<(char const (&data)[N]){
+ if (!is_fixed_length) {
+ *this << N;
+ }
+ uint32_t i;
+ for (i = 0; i < N; i++) {
+ put(data[i]);
+ }
+ while ((i++) % 4 != 0){
+ put('\0');
+ }
+ return *this;
+}
+
XDRStream & XDRStream::operator<<(XDRStream & (*fkt) (XDRStream &))
{
return fkt(*this);
@@ -99,8 +117,21 @@ XDRStream & term(XDRStream & os)
return os;
}
+template<int N>
XDRStream & opaque(XDRStream & os)
{
- os.setNextArrayLen(3);
+ os.setNextArrayLen(N);
+ return os;
+}
+
+XDRStream & fixed(XDRStream & os)
+{
+ os.setFixedLength();
+ return os;
+}
+
+XDRStream & variable(XDRStream & os)
+{
+ os.setVariableLength();
return os;
}