Ice 3.7 C++11 API Reference
OutputStream.h
Go to the documentation of this file.
1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_OUTPUT_STREAM_H
6 #define ICE_OUTPUT_STREAM_H
7 
8 #include <Ice/CommunicatorF.h>
9 #include <Ice/InstanceF.h>
10 #include <Ice/Object.h>
11 #include <Ice/ValueF.h>
12 #include <Ice/ProxyF.h>
13 #include <Ice/Buffer.h>
14 #include <Ice/Protocol.h>
15 #include <Ice/SlicedDataF.h>
16 #include <Ice/StreamHelpers.h>
17 
18 namespace Ice
19 {
20 
21 class UserException;
22 
27 class ICE_API OutputStream : public IceInternal::Buffer
28 {
29 public:
30 
31  typedef size_t size_type;
32 
39 
44  OutputStream(const CommunicatorPtr& communicator);
45 
51  OutputStream(const CommunicatorPtr& communicator, const EncodingVersion& version);
52 
60  OutputStream(const CommunicatorPtr& communicator, const EncodingVersion& version,
61  const std::pair<const Byte*, const Byte*>& bytes);
62 
64  {
65  // Inlined for performance reasons.
66 
67  if(_currentEncaps != &_preAllocatedEncaps)
68  {
69  clear(); // Not inlined.
70  }
71  }
72 
79  void initialize(const CommunicatorPtr& communicator);
80 
88  void initialize(const CommunicatorPtr& communicator, const EncodingVersion& version);
89 
93  void clear();
94 
96  //
97  // Must return Instance*, because we don't hold an InstancePtr for
98  // optimization reasons (see comments below).
99  //
100  IceInternal::Instance* instance() const { return _instance; } // Inlined for performance reasons.
102 
107  void setFormat(FormatType format);
108 
113  void* getClosure() const;
114 
120  void* setClosure(void* p);
121 
127  void swap(OutputStream& other);
128 
130  void resetEncapsulation();
132 
138  void resize(Container::size_type sz)
139  {
140  b.resize(sz);
141  }
142 
148  void startValue(const SlicedDataPtr& data)
149  {
150  assert(_currentEncaps && _currentEncaps->encoder);
151  _currentEncaps->encoder->startInstance(ValueSlice, data);
152  }
153 
157  void endValue()
158  {
159  assert(_currentEncaps && _currentEncaps->encoder);
160  _currentEncaps->encoder->endInstance();
161  }
162 
168  void startException(const SlicedDataPtr& data)
169  {
170  assert(_currentEncaps && _currentEncaps->encoder);
171  _currentEncaps->encoder->startInstance(ExceptionSlice, data);
172  }
173 
178  {
179  assert(_currentEncaps && _currentEncaps->encoder);
180  _currentEncaps->encoder->endInstance();
181  }
182 
188 
195  void startEncapsulation(const EncodingVersion& encoding, FormatType format)
196  {
197  IceInternal::checkSupportedEncoding(encoding);
198 
199  Encaps* oldEncaps = _currentEncaps;
200  if(!oldEncaps) // First allocated encaps?
201  {
202  _currentEncaps = &_preAllocatedEncaps;
203  }
204  else
205  {
206  _currentEncaps = new Encaps();
207  _currentEncaps->previous = oldEncaps;
208  }
209  _currentEncaps->format = format;
210  _currentEncaps->encoding = encoding;
211  _currentEncaps->start = b.size();
212 
213  write(Int(0)); // Placeholder for the encapsulation length.
214  write(_currentEncaps->encoding);
215  }
216 
221  {
222  assert(_currentEncaps);
223 
224  // Size includes size and version.
225  const Int sz = static_cast<Int>(b.size() - _currentEncaps->start);
226  write(sz, &(*(b.begin() + _currentEncaps->start)));
227 
228  Encaps* oldEncaps = _currentEncaps;
229  _currentEncaps = _currentEncaps->previous;
230  if(oldEncaps == &_preAllocatedEncaps)
231  {
232  oldEncaps->reset();
233  }
234  else
235  {
236  delete oldEncaps;
237  }
238  }
239 
245  {
246  IceInternal::checkSupportedEncoding(encoding);
247  write(Int(6)); // Size
248  write(encoding);
249  }
250 
256  void writeEncapsulation(const Byte* v, Int sz)
257  {
258  if(sz < 6)
259  {
260  throwEncapsulationException(__FILE__, __LINE__);
261  }
262 
263  Container::size_type position = b.size();
264  resize(position + static_cast<size_t>(sz));
265  memcpy(&b[position], &v[0], static_cast<size_t>(sz));
266  }
267 
274  {
275  return _currentEncaps ? _currentEncaps->encoding : _encoding;
276  }
277 
285  void startSlice(const std::string& typeId, int compactId, bool last)
286  {
287  assert(_currentEncaps && _currentEncaps->encoder);
288  _currentEncaps->encoder->startSlice(typeId, compactId, last);
289  }
290 
294  void endSlice()
295  {
296  assert(_currentEncaps && _currentEncaps->encoder);
297  _currentEncaps->encoder->endSlice();
298  }
299 
307 
312  void writeSize(Int v) // Inlined for performance reasons.
313  {
314  assert(v >= 0);
315  if(v > 254)
316  {
317  write(Byte(255));
318  write(v);
319  }
320  else
321  {
322  write(static_cast<Byte>(v));
323  }
324  }
325 
332  void rewriteSize(Int v, Container::iterator dest)
333  {
334  assert(v >= 0);
335  if(v > 254)
336  {
337  *dest++ = Byte(255);
338  write(v, dest);
339  }
340  else
341  {
342  *dest = static_cast<Byte>(v);
343  }
344  }
345 
353  {
354  size_type position = b.size();
355  write(Int(0));
356  return position;
357  }
358 
364  void endSize(size_type position)
365  {
366  rewrite(static_cast<Int>(b.size() - position) - 4, position);
367  }
368 
373  void writeBlob(const std::vector<Byte>& v);
374 
380  void writeBlob(const Byte* v, Container::size_type sz)
381  {
382  if(sz > 0)
383  {
384  Container::size_type position = b.size();
385  resize(position + sz);
386  memcpy(&b[position], &v[0], sz);
387  }
388  }
389 
394  template<typename T> void write(const T& v)
395  {
396  StreamHelper<T, StreamableTraits<T>::helper>::write(this, v);
397  }
398 
404  template<typename T> void write(Int tag, const IceUtil::Optional<T>& v)
405  {
406  if(!v)
407  {
408  return; // Optional not set
409  }
410 
411  if(writeOptional(tag, StreamOptionalHelper<T,
412  StreamableTraits<T>::helper,
413  StreamableTraits<T>::fixedLength>::optionalFormat))
414  {
415  StreamOptionalHelper<T,
416  StreamableTraits<T>::helper,
417  StreamableTraits<T>::fixedLength>::write(this, *v);
418  }
419  }
420 
425  template<typename T> void write(const std::vector<T>& v)
426  {
427  if(v.empty())
428  {
429  writeSize(0);
430  }
431  else
432  {
433  write(&v[0], &v[0] + v.size());
434  }
435  }
436 
442  template<typename T> void write(const T* begin, const T* end)
443  {
444  writeSize(static_cast<Int>(end - begin));
445  for(const T* p = begin; p != end; ++p)
446  {
447  write(*p);
448  }
449  }
450 
451 #ifdef ICE_CPP11_MAPPING
452 
456  template<typename T> void writeAll(const T& v)
457  {
458  write(v);
459  }
460 
464  template<typename T, typename... Te> void writeAll(const T& v, const Te&... ve)
465  {
466  write(v);
467  writeAll(ve...);
468  }
469 
473  template<size_t I = 0, typename... Te>
474  typename std::enable_if<I == sizeof...(Te), void>::type
475  writeAll(std::tuple<Te...>)
476  {
477  // Do nothing. Either tuple is empty or we are at the end.
478  }
479 
483  template<size_t I = 0, typename... Te>
484  typename std::enable_if<I < sizeof...(Te), void>::type
485  writeAll(std::tuple<Te...> tuple)
486  {
487  write(std::get<I>(tuple));
488  writeAll<I + 1, Te...>(tuple);
489  }
490 
494  template<typename T>
495  void writeAll(std::initializer_list<int> tags, const IceUtil::Optional<T>& v)
496  {
497  write(*(tags.begin() + tags.size() - 1), v);
498  }
499 
503  template<typename T, typename... Te>
504  void writeAll(std::initializer_list<int> tags, const IceUtil::Optional<T>& v, const IceUtil::Optional<Te>&... ve)
505  {
506  size_t index = tags.size() - sizeof...(ve) - 1;
507  write(*(tags.begin() + index), v);
508  writeAll(tags, ve...);
509  }
510 
511 #endif
512 
520  bool writeOptional(Int tag, OptionalFormat format)
521  {
522  assert(_currentEncaps);
523  if(_currentEncaps->encoder)
524  {
525  return _currentEncaps->encoder->writeOptional(tag, format);
526  }
527  else
528  {
529  return writeOptImpl(tag, format);
530  }
531  }
532 
537  void write(Byte v)
538  {
539  b.push_back(v);
540  }
541 
547  void write(const Byte* start, const Byte* end);
548 
553  void write(bool v)
554  {
555  b.push_back(static_cast<Byte>(v));
556  }
557 
562  void write(const std::vector<bool>& v);
563 
569  void write(const bool* begin, const bool* end);
570 
575  void write(Short v);
576 
582  void write(const Short* begin, const Short* end);
583 
588  void write(Int v) // Inlined for performance reasons.
589  {
590  Container::size_type position = b.size();
591  resize(position + sizeof(Int));
592  write(v, &b[position]);
593  }
594 
601  void write(Int v, Container::iterator dest)
602  {
603 #ifdef ICE_BIG_ENDIAN
604  const Byte* src = reinterpret_cast<const Byte*>(&v) + sizeof(Int) - 1;
605  *dest++ = *src--;
606  *dest++ = *src--;
607  *dest++ = *src--;
608  *dest = *src;
609 #else
610  const Byte* src = reinterpret_cast<const Byte*>(&v);
611  *dest++ = *src++;
612  *dest++ = *src++;
613  *dest++ = *src++;
614  *dest = *src;
615 #endif
616  }
617 
623  void write(const Int* begin, const Int* end);
624 
629  void write(Long v);
630 
636  void write(const Long* begin, const Long* end);
637 
642  void write(Float v);
643 
649  void write(const Float* begin, const Float* end);
650 
655  void write(Double v);
656 
662  void write(const Double* begin, const Double* end);
663 
670  void write(const std::string& v, bool convert = true)
671  {
672  Int sz = static_cast<Int>(v.size());
673  if(convert && sz > 0)
674  {
675  writeConverted(v.data(), static_cast<size_t>(sz));
676  }
677  else
678  {
679  writeSize(sz);
680  if(sz > 0)
681  {
682  Container::size_type position = b.size();
683  resize(position + static_cast<size_t>(sz));
684  memcpy(&b[position], v.data(), static_cast<size_t>(sz));
685  }
686  }
687  }
688 
696  void write(const char* vdata, size_t vsize, bool convert = true)
697  {
698  Int sz = static_cast<Int>(vsize);
699  if(convert && sz > 0)
700  {
701  writeConverted(vdata, vsize);
702  }
703  else
704  {
705  writeSize(sz);
706  if(sz > 0)
707  {
708  Container::size_type position = b.size();
709  resize(position + static_cast<size_t>(sz));
710  memcpy(&b[position], vdata, vsize);
711  }
712  }
713  }
714 
721  void write(const char* vdata, bool convert = true)
722  {
723  write(vdata, strlen(vdata), convert);
724  }
725 
733  void write(const std::string* begin, const std::string* end, bool convert = true);
734 
739  void write(const std::wstring& v);
740 
746  void write(const std::wstring* begin, const std::wstring* end);
747 
748 #ifdef ICE_CPP11_MAPPING
749 
753  void writeProxy(const ::std::shared_ptr<ObjectPrx>& v);
754 
759  template<typename T, typename ::std::enable_if<::std::is_base_of<ObjectPrx, T>::value>::type* = nullptr>
760  void write(const ::std::shared_ptr<T>& v)
761  {
762  writeProxy(::std::static_pointer_cast<ObjectPrx>(v));
763  }
764 #else
765 
769  void write(const ObjectPrx& v);
770 
775  template<typename T> void write(const IceInternal::ProxyHandle<T>& v)
776  {
777  write(ObjectPrx(upCast(v.get())));
778  }
779 #endif
780 
781 #ifdef ICE_CPP11_MAPPING // C++11 mapping
782 
786  template<typename T, typename ::std::enable_if<::std::is_base_of<Value, T>::value>::type* = nullptr>
787  void write(const ::std::shared_ptr<T>& v)
788  {
789  initEncaps();
790  _currentEncaps->encoder->write(v);
791  }
792 #else // C++98 mapping
793 
797  void write(const ObjectPtr& v)
798  {
799  initEncaps();
800  _currentEncaps->encoder->write(v);
801  }
802 
807  template<typename T> void write(const IceInternal::Handle<T>& v)
808  {
809  write(ObjectPtr(upCast(v.get())));
810  }
811 #endif
812 
818  void writeEnum(Int v, Int maxValue);
819 
825 
831  {
832  return b.size();
833  }
834 
841  void rewrite(Int v, size_type pos)
842  {
843  write(v, b.begin() + pos);
844  }
845 
850  void finished(std::vector<Byte>& v);
851 
857  std::pair<const Byte*, const Byte*> finished();
858 
860  OutputStream(IceInternal::Instance*, const EncodingVersion&);
861  void initialize(IceInternal::Instance*, const EncodingVersion&);
862 
863  // Optionals
864  bool writeOptImpl(Int, OptionalFormat);
866 
867 private:
868 
869  //
870  // String
871  //
872  void writeConverted(const char*, size_t);
873 
874  //
875  // We can't throw this exception from inline functions from within
876  // this file, because we cannot include the header with the
877  // exceptions. Doing so would screw up the whole include file
878  // ordering.
879  //
880  void throwEncapsulationException(const char*, int);
881 
882  //
883  // Optimization. The instance may not be deleted while a
884  // stack-allocated stream still holds it.
885  //
886  IceInternal::Instance* _instance;
887 
888  //
889  // The public stream API needs to attach data to a stream.
890  //
891  void* _closure;
892 
893  class Encaps;
894  enum SliceType { NoSlice, ValueSlice, ExceptionSlice };
895 
896  typedef std::vector<ValuePtr> ValueList;
897 
898  class ICE_API EncapsEncoder : private ::IceUtil::noncopyable
899  {
900  public:
901 
902  virtual ~EncapsEncoder();
903 
904  virtual void write(const ValuePtr&) = 0;
905  virtual void write(const UserException&) = 0;
906 
907  virtual void startInstance(SliceType, const SlicedDataPtr&) = 0;
908  virtual void endInstance() = 0;
909  virtual void startSlice(const std::string&, int, bool) = 0;
910  virtual void endSlice() = 0;
911 
912  virtual bool writeOptional(Int, OptionalFormat)
913  {
914  return false;
915  }
916 
917  virtual void writePendingValues()
918  {
919  }
920 
921  protected:
922 
923  EncapsEncoder(OutputStream* stream, Encaps* encaps) : _stream(stream), _encaps(encaps), _typeIdIndex(0)
924  {
925  }
926 
927  Int registerTypeId(const std::string&);
928 
929  OutputStream* _stream;
930  Encaps* _encaps;
931 
932  typedef std::map<ValuePtr, Int> PtrToIndexMap;
933  typedef std::map<std::string, Int> TypeIdMap;
934 
935  // Encapsulation attributes for value marshaling.
936  PtrToIndexMap _marshaledMap;
937 
938  private:
939 
940  // Encapsulation attributes for value marshaling.
941  TypeIdMap _typeIdMap;
942  Int _typeIdIndex;
943  };
944 
945  class ICE_API EncapsEncoder10 : public EncapsEncoder
946  {
947  public:
948 
949  EncapsEncoder10(OutputStream* stream, Encaps* encaps) :
950  EncapsEncoder(stream, encaps), _sliceType(NoSlice), _valueIdIndex(0)
951  {
952  }
953 
954  virtual void write(const ValuePtr&);
955  virtual void write(const UserException&);
956 
957  virtual void startInstance(SliceType, const SlicedDataPtr&);
958  virtual void endInstance();
959  virtual void startSlice(const std::string&, int, bool);
960  virtual void endSlice();
961 
962  virtual void writePendingValues();
963 
964  private:
965 
966  Int registerValue(const ValuePtr&);
967 
968  // Instance attributes
969  SliceType _sliceType;
970 
971  // Slice attributes
972  Container::size_type _writeSlice; // Position of the slice data members
973 
974  // Encapsulation attributes for value marshaling.
975  Int _valueIdIndex;
976  PtrToIndexMap _toBeMarshaledMap;
977  };
978 
979  class ICE_API EncapsEncoder11 : public EncapsEncoder
980  {
981  public:
982 
983  EncapsEncoder11(OutputStream* stream, Encaps* encaps) :
984  EncapsEncoder(stream, encaps), _preAllocatedInstanceData(0), _current(0), _valueIdIndex(1)
985  {
986  }
987 
988  virtual void write(const ValuePtr&);
989  virtual void write(const UserException&);
990 
991  virtual void startInstance(SliceType, const SlicedDataPtr&);
992  virtual void endInstance();
993  virtual void startSlice(const std::string&, int, bool);
994  virtual void endSlice();
995 
996  virtual bool writeOptional(Int, OptionalFormat);
997 
998  private:
999 
1000  void writeSlicedData(const SlicedDataPtr&);
1001  void writeInstance(const ValuePtr&);
1002 
1003  struct InstanceData
1004  {
1005  InstanceData(InstanceData* p) : previous(p), next(0)
1006  {
1007  if(previous)
1008  {
1009  previous->next = this;
1010  }
1011  }
1012 
1013  ~InstanceData()
1014  {
1015  if(next)
1016  {
1017  delete next;
1018  }
1019  }
1020 
1021  // Instance attributes
1022  SliceType sliceType;
1023  bool firstSlice;
1024 
1025  // Slice attributes
1026  Byte sliceFlags;
1027  Container::size_type writeSlice; // Position of the slice data members
1028  Container::size_type sliceFlagsPos; // Position of the slice flags
1029  PtrToIndexMap indirectionMap;
1030  ValueList indirectionTable;
1031 
1032  InstanceData* previous;
1033  InstanceData* next;
1034  };
1035  InstanceData _preAllocatedInstanceData;
1036  InstanceData* _current;
1037 
1038  Int _valueIdIndex; // The ID of the next value to marhsal
1039  };
1040 
1041  class Encaps : private ::IceUtil::noncopyable
1042  {
1043 
1044  public:
1045 
1046  Encaps() : format(ICE_ENUM(FormatType, DefaultFormat)), encoder(0), previous(0)
1047  {
1048  // Inlined for performance reasons.
1049  }
1050  ~Encaps()
1051  {
1052  // Inlined for performance reasons.
1053  delete encoder;
1054  }
1055  void reset()
1056  {
1057  // Inlined for performance reasons.
1058  delete encoder;
1059  encoder = 0;
1060 
1061  previous = 0;
1062  }
1063 
1064  Container::size_type start;
1065  EncodingVersion encoding;
1066  FormatType format;
1067 
1068  EncapsEncoder* encoder;
1069 
1070  Encaps* previous;
1071  };
1072 
1073  //
1074  // The encoding version to use when there's no encapsulation to
1075  // read from or write to. This is for example used to read message
1076  // headers or when the user is using the streaming API with no
1077  // encapsulation.
1078  //
1079  EncodingVersion _encoding;
1080 
1081  FormatType _format;
1082 
1083  Encaps* _currentEncaps;
1084 
1085  void initEncaps();
1086 
1087  Encaps _preAllocatedEncaps;
1088 };
1089 
1090 } // End namespace Ice
1091 
1092 #endif
Ice::OutputStream::write
void write(Long v)
Writes a long to the stream.
Ice::Short
short Short
The mapping for the Slice short type.
Definition: Config.h:52
Ice::OutputStream::write
void write(Byte v)
Writes a byte to the stream.
Definition: OutputStream.h:537
Ice::OutputStream::OutputStream
OutputStream(const CommunicatorPtr &communicator, const EncodingVersion &version)
Constructs a stream using the given communicator and encoding version.
CommunicatorF.h
Ice::OutputStream::writeBlob
void writeBlob(const Byte *v, Container::size_type sz)
Copies the specified blob of bytes to the stream without modification.
Definition: OutputStream.h:380
Ice::OutputStream::setClosure
void * setClosure(void *p)
Associates closure data with this stream.
Ice::OutputStream::startSize
size_type startSize()
Writes a placeholder value for the size and returns the starting position of the size value; after wr...
Definition: OutputStream.h:352
Ice::OutputStream::write
void write(const ::std::shared_ptr< T > &v)
Writes a proxy to the stream.
Definition: OutputStream.h:760
Ice::OutputStream::writeAll
void writeAll(const T &v, const Te &... ve)
Writes a list of mandatory data values.
Definition: OutputStream.h:464
Ice::OutputStream::endValue
void endValue()
Marks the end of a class instance.
Definition: OutputStream.h:157
Ice::Double
double Double
The mapping for the Slice double type.
Definition: Config.h:65
Ice::OutputStream::startEncapsulation
void startEncapsulation()
Writes the start of an encapsulation using the default encoding version and class encoding format.
Ice::OutputStream::writeBlob
void writeBlob(const std::vector< Byte > &v)
Copies the specified blob of bytes to the stream without modification.
Ice::OutputStream::rewrite
void rewrite(Int v, size_type pos)
Overwrite a 32-bit integer value at the given position in the stream.
Definition: OutputStream.h:841
Ice::OutputStream::endSlice
void endSlice()
Marks the end of a value or exception slice.
Definition: OutputStream.h:294
Ice::OutputStream::size_type
size_t size_type
Definition: OutputStream.h:31
Ice::OutputStream::write
void write(Short v)
Writes a short to the stream.
StreamHelpers.h
Ice::OutputStream::writeSize
void writeSize(Int v)
Writes a size value.
Definition: OutputStream.h:312
InstanceF.h
ICE_ENUM
#define ICE_ENUM(CLASS, ENUMERATOR)
Definition: Config.h:360
IceUtil::Optional
std::experimental::Ice::optional< T > Optional
For compatibility with the Ice C++98 mapping, do not use in new code:
Definition: Optional.h:1100
Ice::OutputStream::write
void write(const Long *begin, const Long *end)
Writes a long sequence to the stream.
Ice::Float
float Float
The mapping for the Slice float type.
Definition: Config.h:63
Ice::upCast
IceUtil::Shared * upCast(::Ice::LocalObject *)
Ice::OutputStream::pos
size_type pos()
Obtains the current position of the stream.
Definition: OutputStream.h:830
Ice::OutputStream::write
void write(Int tag, const IceUtil::Optional< T > &v)
Writes an optional data value to the stream.
Definition: OutputStream.h:404
Ice::OutputStream::getEncoding
const EncodingVersion & getEncoding() const
Determines the current encoding version.
Definition: OutputStream.h:273
Ice::OutputStream::finished
void finished(std::vector< Byte > &v)
Indicates that marshaling is complete.
Ice::OutputStream::writeException
void writeException(const UserException &v)
Writes an exception to the stream.
ICE_API
#define ICE_API
Definition: Config.h:197
Ice::OutputStream::writeAll
std::enable_if< I==sizeof...(Te), void >::type writeAll(std::tuple< Te... >)
Writes a list of mandatory data values.
Definition: OutputStream.h:475
Ice::EncodingVersion
A version structure for the encoding version.
Definition: Version.h:82
Ice::OutputStream::finished
std::pair< const Byte *, const Byte * > finished()
Indicates that marshaling is complete.
Ice::OutputStream::write
void write(const std::vector< T > &v)
Writes a sequence of data values to the stream.
Definition: OutputStream.h:425
Ice::initialize
CommunicatorPtr initialize(int &argc, const char *argv[], const InitializationData &initData=InitializationData(), int version=30710)
Initializes a new communicator.
Protocol.h
Ice::Byte
unsigned char Byte
The mapping for the Slice byte type.
Definition: Config.h:50
Ice::OutputStream::write
void write(const std::string &v, bool convert=true)
Writes a string to the stream.
Definition: OutputStream.h:670
Ice::OutputStream::~OutputStream
~OutputStream()
Definition: OutputStream.h:63
Ice::OutputStream::write
void write(const Float *begin, const Float *end)
Writes a float sequence to the stream.
Ice::OutputStream::write
void write(const T &v)
Writes a data value to the stream.
Definition: OutputStream.h:394
Ice::OutputStream::write
void write(Double v)
Writes a double to the stream.
Ice::OutputStream::write
void write(const char *vdata, size_t vsize, bool convert=true)
Writes a string to the stream.
Definition: OutputStream.h:696
Ice::OutputStream::write
void write(const Byte *start, const Byte *end)
Writes a byte sequence to the stream.
Ice::OutputStream::write
void write(const bool *begin, const bool *end)
Writes a byte sequence to the stream.
Ice::OutputStream::swap
void swap(OutputStream &other)
Swaps the contents of one stream with another.
Ice::OutputStream::writeEncapsulation
void writeEncapsulation(const Byte *v, Int sz)
Copies the marshaled form of an encapsulation to the buffer.
Definition: OutputStream.h:256
Ice::OutputStream::write
void write(const T *begin, const T *end)
Writes a sequence of data values to the stream.
Definition: OutputStream.h:442
ProxyF.h
SlicedDataF.h
IceUtil::noncopyable
Definition: Config.h:313
Ice::OutputStream::resize
void resize(Container::size_type sz)
Resizes the stream to a new size.
Definition: OutputStream.h:138
Buffer.h
Ice::OutputStream::write
void write(const Int *begin, const Int *end)
Writes an int sequence to the stream.
Ice::OutputStream::write
void write(const char *vdata, bool convert=true)
Writes a string to the stream.
Definition: OutputStream.h:721
Ice::OutputStream::clear
void clear()
Releases any data retained by encapsulations.
Object.h
Ice::OutputStream::write
void write(const Double *begin, const Double *end)
Writes a double sequence to the stream.
Ice::FormatType
FormatType
Describes the possible formats for classes and exceptions.
Definition: Format.h:21
Ice::OutputStream
Interface for output streams used to create a sequence of bytes from Slice types.
Definition: OutputStream.h:28
Ice::OutputStream::endException
void endException()
Marks the end of an exception instance.
Definition: OutputStream.h:177
Ice::OutputStream::write
void write(bool v)
Writes a boolean to the stream.
Definition: OutputStream.h:553
Ice::OutputStream::startValue
void startValue(const SlicedDataPtr &data)
Marks the start of a class instance.
Definition: OutputStream.h:148
Ice::OutputStream::OutputStream
OutputStream(const CommunicatorPtr &communicator)
Constructs a stream using the communicator's default encoding version.
Ice::OutputStream::writeEmptyEncapsulation
void writeEmptyEncapsulation(const EncodingVersion &encoding)
Writes an empty encapsulation using the given encoding version.
Definition: OutputStream.h:244
Ice::OutputStream::writeAll
void writeAll(const T &v)
Writes a list of mandatory data values.
Definition: OutputStream.h:456
Ice::OutputStream::write
void write(Int v, Container::iterator dest)
Overwrites a 32-bit integer value at the given destination in the stream.
Definition: OutputStream.h:601
Ice::OutputStream::setFormat
void setFormat(FormatType format)
Sets the class encoding format.
Ice::OutputStream::getClosure
void * getClosure() const
Obtains the closure data associated with this stream.
Ice::Long
long long int Long
The mapping for the Slice long type.
Definition: Config.h:57
Ice::OutputStream::writePendingValues
void writePendingValues()
Encodes the state of class instances whose insertion was delayed during a previous call to write.
Ice::OutputStream::startSlice
void startSlice(const std::string &typeId, int compactId, bool last)
Writes the start of a value or exception slice.
Definition: OutputStream.h:285
Ice
Definition: BuiltinSequences.h:56
Ice::OutputStream::OutputStream
OutputStream(const CommunicatorPtr &communicator, const EncodingVersion &version, const std::pair< const Byte *, const Byte * > &bytes)
Constructs a stream using the given communicator and encoding version.
Ice::OutputStream::initialize
void initialize(const CommunicatorPtr &communicator)
Initializes the stream to use the communicator's default encoding version, class encoding format and ...
Ice::ObjectPrx
Base class of all object proxies.
Definition: Proxy.h:317
Ice::OutputStream::write
void write(const std::string *begin, const std::string *end, bool convert=true)
Writes a string sequence to the stream.
Ice::OutputStream::startException
void startException(const SlicedDataPtr &data)
Marks the start of an exception instance.
Definition: OutputStream.h:168
Ice::OutputStream::write
void write(Int v)
Writes an int to the stream.
Definition: OutputStream.h:588
Ice::OutputStream::startEncapsulation
void startEncapsulation(const EncodingVersion &encoding, FormatType format)
Writes the start of an encapsulation using the given encoding version and class encoding format.
Definition: OutputStream.h:195
Ice::OutputStream::writeEnum
void writeEnum(Int v, Int maxValue)
Writes an enumerator to the stream.
Ice::OutputStream::write
void write(const std::vector< bool > &v)
Writes a byte sequence to the stream.
Ice::OutputStream::rewriteSize
void rewriteSize(Int v, Container::iterator dest)
Replaces a size value at the given destination in the stream.
Definition: OutputStream.h:332
Ice::OutputStream::endSize
void endSize(size_type position)
Updates the size value at the given position to contain a size based on the stream's current position...
Definition: OutputStream.h:364
Ice::OutputStream::endEncapsulation
void endEncapsulation()
Ends the current encapsulation.
Definition: OutputStream.h:220
Ice::OutputStream::write
void write(Float v)
Writes a float to the stream.
Ice::OutputStream::write
void write(const Short *begin, const Short *end)
Writes a short sequence to the stream.
ValueF.h
Ice::OutputStream::write
void write(const std::wstring *begin, const std::wstring *end)
Writes a wide string sequence to the stream.
Ice::OutputStream::initialize
void initialize(const CommunicatorPtr &communicator, const EncodingVersion &version)
Initializes the stream to use the given encoding version and the communicator's default class encodin...
Ice::Int
int Int
The mapping for the Slice int type.
Definition: Config.h:54
Ice::OutputStream::OutputStream
OutputStream()
Constructs an OutputStream using the latest encoding version, the default format for class encoding,...
Ice::OutputStream::writeProxy
void writeProxy(const ::std::shared_ptr< ObjectPrx > &v)
Writes a proxy to the stream.
Ice::OutputStream::write
void write(const std::wstring &v)
Writes a wide string to the stream.
Ice::UserException
Base class for all Ice user exceptions.
Definition: Exception.h:68