RDKit
Open-source cheminformatics and machine learning.
StreamOps.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2008 Greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 //
11 #include <RDGeneral/export.h>
12 #ifndef _RD_STREAMOPS_H
13 #define _RD_STREAMOPS_H
14 
15 #include "types.h"
16 #include "Invariant.h"
17 #include "RDProps.h"
18 #include <string>
19 #include <sstream>
20 #include <iostream>
21 #include <boost/cstdint.hpp>
22 #include <boost/predef.h>
23 
24 namespace RDKit {
25 // this code block for handling endian problems is adapted from :
26 // http://stackoverflow.com/questions/105252/how-do-i-convert-between-big-endian-and-little-endian-values-in-c
27 enum EEndian {
30 #if defined(BOOST_ENDIAN_LITTLE_BYTE) || defined(BOOST_ENDIAN_LITTLE_WORD)
31  HOST_ENDIAN_ORDER = LITTLE_ENDIAN_ORDER
32 #elif defined(BOOST_ENDIAN_BIG_BYTE)
33  HOST_ENDIAN_ORDER = BIG_ENDIAN_ORDER
34 #elif defined(BOOST_ENDIAN_BIG_WORD)
35 #error "Cannot compile on word-swapped big-endian systems"
36 #else
37 #error "Failed to determine the system endian value"
38 #endif
39 };
40 
41 // this function swap the bytes of values given it's size as a template
42 // parameter (could sizeof be used?).
43 template <class T, unsigned int size>
44 inline T SwapBytes(T value) {
45  if (size < 2) return value;
46 
47  union {
48  T value;
49  char bytes[size];
50  } in, out;
51 
52  in.value = value;
53 
54  for (unsigned int i = 0; i < size; ++i) {
55  out.bytes[i] = in.bytes[size - 1 - i];
56  }
57 
58  return out.value;
59 }
60 
61 // Here is the function you will use. Again there is two compile-time assertion
62 // that use the boost librarie. You could probably comment them out, but if you
63 // do be cautious not to use this function for anything else than integers
64 // types. This function need to be calles like this :
65 //
66 // int x = someValue;
67 // int i = EndianSwapBytes<HOST_ENDIAN_ORDER, BIG_ENDIAN_ORDER>(x);
68 //
69 template <EEndian from, EEndian to, class T>
70 inline T EndianSwapBytes(T value) {
71  // A : La donnée à swapper à une taille de 2, 4 ou 8 octets
72  BOOST_STATIC_ASSERT(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 ||
73  sizeof(T) == 8);
74  if (sizeof(T) == 1) return value;
75 
76  // A : La donnée à swapper est d'un type arithmetic
77  // BOOST_STATIC_ASSERT(boost::is_arithmetic<T>::value);
78 
79  // Si from et to sont du même type on ne swap pas.
80  if (from == to) return value;
81 
82  return SwapBytes<T, sizeof(T)>(value);
83 }
84 template <EEndian from, EEndian to>
85 inline char EndianSwapBytes(char value) {
86  return value;
87 }
88 template <EEndian from, EEndian to>
89 inline unsigned char EndianSwapBytes(unsigned char value) {
90  return value;
91 }
92 template <EEndian from, EEndian to>
93 inline signed char EndianSwapBytes(signed char value) {
94  return value;
95 }
96 // --------------------------------------
97 
98 //! Packs an integer and outputs it to a stream
99 inline void appendPackedIntToStream(std::stringstream &ss,
100  boost::uint32_t num) {
101  int nbytes, bix;
102  unsigned int val, res;
103  char tc;
104 
105  res = num;
106  while (1) {
107  if (res < (1 << 7)) {
108  val = (res << 1);
109  nbytes = 1;
110  break;
111  }
112  res -= (1 << 7);
113  if (res < (1 << 14)) {
114  val = ((res << 2) | 1);
115  nbytes = 2;
116  break;
117  }
118  res -= (1 << 14);
119  if (res < (1 << 21)) {
120  val = ((res << 3) | 3);
121  nbytes = 3;
122  break;
123  }
124  res -= (1 << 21);
125  if (res < (1 << 29)) {
126  val = ((res << 3) | 7);
127  nbytes = 4;
128  break;
129  } else {
130  CHECK_INVARIANT(0, "ERROR: Integer too big to pack\n");
131  }
132  }
133  // val = EndianSwapBytes<HOST_ENDIAN_ORDER,LITTLE_ENDIAN_ORDER>(val);
134 
135  for (bix = 0; bix < nbytes; bix++) {
136  tc = (char)(val & 255);
137  ss.write(&tc, 1);
138  val >>= 8;
139  }
140 }
141 
142 //! Reads an integer from a stream in packed format and returns the result.
143 inline boost::uint32_t readPackedIntFromStream(std::stringstream &ss) {
144  boost::uint32_t val, num;
145  int shift, offset;
146  char tmp;
147  ss.read(&tmp, sizeof(tmp));
148  val = UCHAR(tmp);
149  offset = 0;
150  if ((val & 1) == 0) {
151  shift = 1;
152  } else if ((val & 3) == 1) {
153  ss.read((char *)&tmp, sizeof(tmp));
154  val |= (UCHAR(tmp) << 8);
155  shift = 2;
156  offset = (1 << 7);
157  } else if ((val & 7) == 3) {
158  ss.read((char *)&tmp, sizeof(tmp));
159  val |= (UCHAR(tmp) << 8);
160  ss.read((char *)&tmp, sizeof(tmp));
161  val |= (UCHAR(tmp) << 16);
162  shift = 3;
163  offset = (1 << 7) + (1 << 14);
164  } else {
165  ss.read((char *)&tmp, sizeof(tmp));
166  val |= (UCHAR(tmp) << 8);
167  ss.read((char *)&tmp, sizeof(tmp));
168  val |= (UCHAR(tmp) << 16);
169  ss.read((char *)&tmp, sizeof(tmp));
170  val |= (UCHAR(tmp) << 24);
171  shift = 3;
172  offset = (1 << 7) + (1 << 14) + (1 << 21);
173  }
174  num = (val >> shift) + offset;
175  // num = EndianSwapBytes<LITTLE_ENDIAN_ORDER,HOST_ENDIAN_ORDER>(num);
176  return num;
177 }
178 
179 //! Reads an integer from a char * in packed format and returns the result.
180 //! The argument is advanced
181 inline boost::uint32_t pullPackedIntFromString(const char *&text) {
182  boost::uint32_t val, num;
183  int shift, offset;
184  char tmp;
185  tmp = *text;
186  text++;
187  val = UCHAR(tmp);
188  offset = 0;
189  if ((val & 1) == 0) {
190  shift = 1;
191  } else if ((val & 3) == 1) {
192  tmp = *text;
193  text++;
194  val |= (UCHAR(tmp) << 8);
195  shift = 2;
196  offset = (1 << 7);
197  } else if ((val & 7) == 3) {
198  tmp = *text;
199  text++;
200  val |= (UCHAR(tmp) << 8);
201  tmp = *text;
202  text++;
203  val |= (UCHAR(tmp) << 16);
204  shift = 3;
205  offset = (1 << 7) + (1 << 14);
206  } else {
207  tmp = *text;
208  text++;
209  val |= (UCHAR(tmp) << 8);
210  tmp = *text;
211  text++;
212  val |= (UCHAR(tmp) << 16);
213  tmp = *text;
214  text++;
215  val |= (UCHAR(tmp) << 24);
216  shift = 3;
217  offset = (1 << 7) + (1 << 14) + (1 << 21);
218  }
219  num = (val >> shift) + offset;
220  // num = EndianSwapBytes<LITTLE_ENDIAN_ORDER,HOST_ENDIAN_ORDER>(num);
221  return num;
222 }
223 
224 //! does a binary write of an object to a stream
225 template <typename T>
226 void streamWrite(std::ostream &ss, const T &val) {
227  T tval = EndianSwapBytes<HOST_ENDIAN_ORDER, LITTLE_ENDIAN_ORDER>(val);
228  ss.write((const char *)&tval, sizeof(T));
229 }
230 
231 //! special case for string
232 inline void streamWrite(std::ostream &ss, const std::string &what) {
233  unsigned int l = rdcast<unsigned int>(what.length());
234  ss.write((const char *)&l, sizeof(l));
235  ss.write(what.c_str(), sizeof(char) * l);
236 };
237 
238 template <typename T>
239 void streamWriteVec(std::ostream &ss, const T &val) {
240  streamWrite(ss, static_cast<boost::uint64_t>(val.size()));
241  for (size_t i = 0; i < val.size(); ++i) streamWrite(ss, val[i]);
242 }
243 
244 //! does a binary read of an object from a stream
245 template <typename T>
246 void streamRead(std::istream &ss, T &loc) {
247  T tloc;
248  ss.read((char *)&tloc, sizeof(T));
249  loc = EndianSwapBytes<LITTLE_ENDIAN_ORDER, HOST_ENDIAN_ORDER>(tloc);
250 }
251 
252 //! special case for string
253 template <class T>
254 void streamRead(std::istream &ss, T &obj, int version) {
255  RDUNUSED_PARAM(version);
256  streamRead(ss, obj);
257 }
258 
259 inline void streamRead(std::istream &ss, std::string &what, int version) {
260  RDUNUSED_PARAM(version);
261  unsigned int l;
262  ss.read((char *)&l, sizeof(l));
263  char *buff = new char[l];
264  ss.read(buff, sizeof(char) * l);
265  what = std::string(buff, l);
266  delete[] buff;
267 };
268 
269 template <class T>
270 void streamReadVec(std::istream &ss, T &val) {
271  boost::uint64_t size;
272  streamRead(ss, size);
273  val.resize(size);
274 
275  for (size_t i = 0; i < size; ++i) streamRead(ss, val[i]);
276 }
277 
278 inline void streamReadStringVec(std::istream &ss, std::vector<std::string> &val,
279  int version) {
280  boost::uint64_t size;
281  streamRead(ss, size);
282  val.resize(size);
283 
284  for (size_t i = 0; i < size; ++i) streamRead(ss, val[i], version);
285 }
286 
287 //! grabs the next line from an instream and returns it.
288 inline std::string getLine(std::istream *inStream) {
289  std::string res;
290  std::getline(*inStream, res);
291  if ((res.length() > 0) && (res[res.length() - 1] == '\r')) {
292  res.erase(res.length() - 1);
293  }
294  return res;
295 }
296 //! grabs the next line from an instream and returns it.
297 inline std::string getLine(std::istream &inStream) {
298  return getLine(&inStream);
299 }
300 
301 // n.b. We can't use RDTypeTag directly, they are implementation
302 // specific
303 namespace DTags {
304 const unsigned char StringTag = 0;
305 const unsigned char IntTag = 1;
306 const unsigned char UnsignedIntTag = 2;
307 const unsigned char BoolTag = 3;
308 const unsigned char FloatTag = 4;
309 const unsigned char DoubleTag = 5;
310 const unsigned char VecStringTag = 6;
311 const unsigned char VecIntTag = 7;
312 const unsigned char VecUIntTag = 8;
313 const unsigned char VecBoolTag = 9;
314 const unsigned char VecFloatTag = 10;
315 const unsigned char VecDoubleTag = 11;
316 
317 const unsigned char CustomTag = 0xFE; // custom data
318 const unsigned char EndTag = 0xFF;
319 } // namespace DTags
320 
322  public:
323  virtual ~CustomPropHandler(){};
324  virtual const char *getPropName() const = 0;
325  virtual bool canSerialize(const RDValue &value) const = 0;
326  virtual bool read(std::istream &ss, RDValue &value) const = 0;
327  virtual bool write(std::ostream &ss, const RDValue &value) const = 0;
328  virtual CustomPropHandler *clone() const = 0;
329 };
330 
331 typedef std::vector<std::shared_ptr<const CustomPropHandler>>
333 
334 inline bool isSerializable(const Dict::Pair &pair,
335  const CustomPropHandlerVec &handlers = {}) {
336  switch (pair.val.getTag()) {
338  case RDTypeTag::IntTag:
340  case RDTypeTag::BoolTag:
341  case RDTypeTag::FloatTag:
343 
349  return true;
350  case RDTypeTag::AnyTag:
351  for (auto &handler : handlers) {
352  if (handler->canSerialize(pair.val)) {
353  return true;
354  }
355  }
356  return false;
357  default:
358  return false;
359  }
360 }
361 
362 inline bool streamWriteProp(std::ostream &ss, const Dict::Pair &pair,
363  const CustomPropHandlerVec &handlers = {}) {
364  if (!isSerializable(pair, handlers)) {
365  return false;
366  }
367 
368  streamWrite(ss, pair.key);
369  switch (pair.val.getTag()) {
372  streamWrite(ss, rdvalue_cast<std::string>(pair.val));
373  break;
374  case RDTypeTag::IntTag:
376  streamWrite(ss, rdvalue_cast<int>(pair.val));
377  break;
381  break;
382  case RDTypeTag::BoolTag:
385  break;
386  case RDTypeTag::FloatTag:
389  break;
393  break;
394 
397  streamWriteVec(ss, rdvalue_cast<std::vector<std::string>>(pair.val));
398  break;
401  streamWriteVec(ss, rdvalue_cast<std::vector<double>>(pair.val));
402  break;
405  streamWriteVec(ss, rdvalue_cast<std::vector<float>>(pair.val));
406  break;
409  streamWriteVec(ss, rdvalue_cast<std::vector<int>>(pair.val));
410  break;
413  streamWriteVec(ss, rdvalue_cast<std::vector<unsigned int>>(pair.val));
414  break;
415  default:
416  for (auto &handler : handlers) {
417  if (handler->canSerialize(pair.val)) {
418  // The form of a custom tag is
419  // CustomTag
420  // customPropName (must be unique)
421  // custom serialization
423  streamWrite(ss, std::string(handler->getPropName()));
424  handler->write(ss, pair.val);
425  return true;
426  }
427  }
428 
429  return false;
430  }
431  return true;
432 }
433 
434 inline bool streamWriteProps(std::ostream &ss, const RDProps &props,
435  bool savePrivate = false,
436  bool saveComputed = false,
437  const CustomPropHandlerVec &handlers = {}) {
438  STR_VECT propsToSave = props.getPropList(savePrivate, saveComputed);
439  std::set<std::string> propnames(propsToSave.begin(), propsToSave.end());
440 
441  const Dict &dict = props.getDict();
442  unsigned int count = 0;
443  for (Dict::DataType::const_iterator it = dict.getData().begin();
444  it != dict.getData().end(); ++it) {
445  if (propnames.find(it->key) != propnames.end()) {
446  if (isSerializable(*it, handlers)) {
447  count++;
448  }
449  }
450  }
451 
452  streamWrite(ss, count); // packed int?
453 
454  unsigned int writtenCount = 0;
455  for (Dict::DataType::const_iterator it = dict.getData().begin();
456  it != dict.getData().end(); ++it) {
457  if (propnames.find(it->key) != propnames.end()) {
458  if (isSerializable(*it, handlers)) {
459  // note - not all properties are serializable, this may be
460  // a null op
461  if (streamWriteProp(ss, *it, handlers)) {
462  writtenCount++;
463  }
464  }
465  }
466  }
467  POSTCONDITION(count == writtenCount,
468  "Estimated property count not equal to written");
469  return true;
470 }
471 
472 template <class T>
473 void readRDValue(std::istream &ss, RDValue &value) {
474  T v;
475  streamRead(ss, v);
476  value = v;
477 }
478 
479 template <class T>
480 void readRDVecValue(std::istream &ss, RDValue &value) {
481  std::vector<T> v;
482  streamReadVec(ss, v);
483  value = v;
484 }
485 
486 inline void readRDValueString(std::istream &ss, RDValue &value) {
487  std::string v;
488  int version = 0;
489  streamRead(ss, v, version);
490  value = v;
491 }
492 
493 inline void readRDStringVecValue(std::istream &ss, RDValue &value) {
494  std::vector<std::string> v;
495  int version = 0;
496  streamReadStringVec(ss, v, version);
497  value = v;
498 }
499 
500 inline bool streamReadProp(std::istream &ss, Dict::Pair &pair,
501  bool &dictHasNonPOD,
502  const CustomPropHandlerVec &handlers = {}) {
503  int version = 0;
504  streamRead(ss, pair.key, version);
505 
506  unsigned char type;
507  streamRead(ss, type);
508  switch (type) {
509  case DTags::IntTag:
510  readRDValue<int>(ss, pair.val);
511  break;
513  readRDValue<unsigned int>(ss, pair.val);
514  break;
515  case DTags::BoolTag:
516  readRDValue<bool>(ss, pair.val);
517  break;
518  case DTags::FloatTag:
519  readRDValue<float>(ss, pair.val);
520  break;
521  case DTags::DoubleTag:
522  readRDValue<double>(ss, pair.val);
523  break;
524 
525  case DTags::StringTag:
526  readRDValueString(ss, pair.val);
527  dictHasNonPOD = true;
528  break;
529  case DTags::VecStringTag:
530  readRDStringVecValue(ss, pair.val);
531  dictHasNonPOD = true;
532  break;
533  case DTags::VecIntTag:
534  readRDVecValue<int>(ss, pair.val);
535  dictHasNonPOD = true;
536  break;
537  case DTags::VecUIntTag:
538  readRDVecValue<unsigned int>(ss, pair.val);
539  dictHasNonPOD = true;
540  break;
541  case DTags::VecFloatTag:
542  readRDVecValue<float>(ss, pair.val);
543  dictHasNonPOD = true;
544  break;
545  case DTags::VecDoubleTag:
546  readRDVecValue<double>(ss, pair.val);
547  dictHasNonPOD = true;
548  break;
549  case DTags::CustomTag: {
550  std::string propType;
551  int version = 0;
552  streamRead(ss, propType, version);
553  for (auto &handler : handlers) {
554  if (propType == handler->getPropName()) {
555  handler->read(ss, pair.val);
556  dictHasNonPOD = true;
557  return true;
558  }
559  }
560  return false;
561  }
562 
563  default:
564  return false;
565  }
566  return true;
567 }
568 
569 inline unsigned int streamReadProps(std::istream &ss, RDProps &props,
570  const CustomPropHandlerVec &handlers = {}) {
571  unsigned int count;
572  streamRead(ss, count);
573 
574  Dict &dict = props.getDict();
575  dict.reset(); // Clear data before repopulating
576  dict.getData().resize(count);
577  for (unsigned index = 0; index < count; ++index) {
578  CHECK_INVARIANT(streamReadProp(ss, dict.getData()[index],
579  dict.getNonPODStatus(), handlers),
580  "Corrupted property serialization detected");
581  }
582 
583  return count;
584 }
585 
586 } // namespace RDKit
587 
588 #endif
RDKit::streamReadStringVec
void streamReadStringVec(std::istream &ss, std::vector< std::string > &val, int version)
Definition: StreamOps.h:278
RDKit::UCHAR
unsigned char UCHAR
Definition: types.h:252
POSTCONDITION
#define POSTCONDITION(expr, mess)
Definition: Invariant.h:117
RDKit::RDProps::getDict
const Dict & getDict() const
gets the underlying Dictionary
Definition: RDProps.h:27
RDKit::DTags::VecStringTag
const unsigned char VecStringTag
Definition: StreamOps.h:310
RDKit::Dict::Pair::key
std::string key
Definition: Dict.h:39
RDKit::DTags::VecIntTag
const unsigned char VecIntTag
Definition: StreamOps.h:311
RDKit::pullPackedIntFromString
boost::uint32_t pullPackedIntFromString(const char *&text)
Definition: StreamOps.h:181
RDKit::readRDValue
void readRDValue(std::istream &ss, RDValue &value)
Definition: StreamOps.h:473
RDKit::rdvalue_cast< bool >
bool rdvalue_cast< bool >(RDValue_cast_t v)
Definition: RDValue-doublemagic.h:471
RDKit::CustomPropHandler::canSerialize
virtual bool canSerialize(const RDValue &value) const =0
types.h
RDKit::DTags::VecDoubleTag
const unsigned char VecDoubleTag
Definition: StreamOps.h:315
RDKit::CustomPropHandler::clone
virtual CustomPropHandler * clone() const =0
RDKit::RDTypeTag::FloatTag
static const boost::uint64_t FloatTag
Definition: RDValue-doublemagic.h:97
RDKit::EndianSwapBytes
T EndianSwapBytes(T value)
Definition: StreamOps.h:70
RDKit::CustomPropHandler
Definition: StreamOps.h:321
RDKit::RDProps::getPropList
STR_VECT getPropList(bool includePrivate=true, bool includeComputed=true) const
returns a list with the names of our properties
Definition: RDProps.h:36
RDKit::streamReadProp
bool streamReadProp(std::istream &ss, Dict::Pair &pair, bool &dictHasNonPOD, const CustomPropHandlerVec &handlers={})
Definition: StreamOps.h:500
RDKit::appendPackedIntToStream
void appendPackedIntToStream(std::stringstream &ss, boost::uint32_t num)
Packs an integer and outputs it to a stream.
Definition: StreamOps.h:99
RDKit::RDTypeTag::UnsignedIntTag
static const boost::uint64_t UnsignedIntTag
Definition: RDValue-doublemagic.h:99
RDKit::CustomPropHandler::getPropName
virtual const char * getPropName() const =0
RDKit::streamReadVec
void streamReadVec(std::istream &ss, T &val)
Definition: StreamOps.h:270
RDKit::DTags::VecUIntTag
const unsigned char VecUIntTag
Definition: StreamOps.h:312
RDKit::RDValue
Definition: RDValue-doublemagic.h:167
RDKit::DTags::FloatTag
const unsigned char FloatTag
Definition: StreamOps.h:308
RDKit::DTags::CustomTag
const unsigned char CustomTag
Definition: StreamOps.h:317
RDKit::streamWriteProps
bool streamWriteProps(std::ostream &ss, const RDProps &props, bool savePrivate=false, bool saveComputed=false, const CustomPropHandlerVec &handlers={})
Definition: StreamOps.h:434
RDKit::getLine
std::string getLine(std::istream *inStream)
grabs the next line from an instream and returns it.
Definition: StreamOps.h:288
RDKit::RDTypeTag::DoubleTag
static const boost::uint64_t DoubleTag
Definition: RDValue-doublemagic.h:96
CHECK_INVARIANT
#define CHECK_INVARIANT(expr, mess)
Definition: Invariant.h:101
RDKit::RDTypeTag::VecDoubleTag
static const boost::uint64_t VecDoubleTag
Definition: RDValue-doublemagic.h:105
RDKit::streamRead
void streamRead(std::istream &ss, T &loc)
does a binary read of an object from a stream
Definition: StreamOps.h:246
RDKit::RDTypeTag::VecUnsignedIntTag
static const boost::uint64_t VecUnsignedIntTag
Definition: RDValue-doublemagic.h:108
RDKit::LITTLE_ENDIAN_ORDER
@ LITTLE_ENDIAN_ORDER
Definition: StreamOps.h:28
RDKit::CustomPropHandler::read
virtual bool read(std::istream &ss, RDValue &value) const =0
RDKit::readRDVecValue
void readRDVecValue(std::istream &ss, RDValue &value)
Definition: StreamOps.h:480
RDKit::CustomPropHandlerVec
std::vector< std::shared_ptr< const CustomPropHandler > > CustomPropHandlerVec
Definition: StreamOps.h:332
RDUNUSED_PARAM
#define RDUNUSED_PARAM(x)
Definition: Invariant.h:196
RDKit::rdvalue_cast< int >
int rdvalue_cast< int >(RDValue_cast_t v)
Definition: RDValue-doublemagic.h:458
RDKit::STR_VECT
std::vector< std::string > STR_VECT
Definition: Dict.h:29
RDKit::SwapBytes
T SwapBytes(T value)
Definition: StreamOps.h:44
RDKit::DTags::VecFloatTag
const unsigned char VecFloatTag
Definition: StreamOps.h:314
RDKit::Dict::Pair::val
RDValue val
Definition: Dict.h:40
RDKit::rdvalue_cast
T rdvalue_cast(RDValue_cast_t v)
Definition: RDValue-doublemagic.h:420
RDKit::DTags::StringTag
const unsigned char StringTag
Definition: StreamOps.h:304
RDKit::rdvalue_cast< unsigned int >
unsigned int rdvalue_cast< unsigned int >(RDValue_cast_t v)
Definition: RDValue-doublemagic.h:464
RDKit::RDTypeTag::VecFloatTag
static const boost::uint64_t VecFloatTag
Definition: RDValue-doublemagic.h:106
RDKit::DTags::UnsignedIntTag
const unsigned char UnsignedIntTag
Definition: StreamOps.h:306
RDKit::streamWrite
void streamWrite(std::ostream &ss, const T &val)
does a binary write of an object to a stream
Definition: StreamOps.h:226
RDKit::readPackedIntFromStream
boost::uint32_t readPackedIntFromStream(std::stringstream &ss)
Reads an integer from a stream in packed format and returns the result.
Definition: StreamOps.h:143
RDKit::RDTypeTag::AnyTag
static const boost::uint64_t AnyTag
Definition: RDValue-doublemagic.h:110
RDKit::DTags::VecBoolTag
const unsigned char VecBoolTag
Definition: StreamOps.h:313
RDKit::RDTypeTag::IntTag
static const boost::uint64_t IntTag
Definition: RDValue-doublemagic.h:98
RDKit::Dict::reset
void reset()
Clears all keys (and values) from the dictionary.
Definition: Dict.h:291
RDKit::streamWriteProp
bool streamWriteProp(std::ostream &ss, const Dict::Pair &pair, const CustomPropHandlerVec &handlers={})
Definition: StreamOps.h:362
RDProps.h
RDKit::DTags::EndTag
const unsigned char EndTag
Definition: StreamOps.h:318
Invariant.h
RDKit::RDProps
Definition: RDProps.h:10
RDKit::RDTypeTag::VecIntTag
static const boost::uint64_t VecIntTag
Definition: RDValue-doublemagic.h:107
RDKit::RDTypeTag::StringTag
static const boost::uint64_t StringTag
Definition: RDValue-doublemagic.h:104
RDKit::readRDValueString
void readRDValueString(std::istream &ss, RDValue &value)
Definition: StreamOps.h:486
RDKit
Std stuff.
Definition: Atom.h:30
RDKit::RDTypeTag::BoolTag
static const boost::uint64_t BoolTag
Definition: RDValue-doublemagic.h:100
RDKit::DTags::IntTag
const unsigned char IntTag
Definition: StreamOps.h:305
RDKit::rdvalue_cast< double >
double rdvalue_cast< double >(RDValue_cast_t v)
Definition: RDValue-doublemagic.h:440
RDKit::RDValue::getTag
boost::uint64_t getTag() const
Definition: RDValue-doublemagic.h:282
RDKit::EEndian
EEndian
Definition: StreamOps.h:27
RDKit::BIG_ENDIAN_ORDER
@ BIG_ENDIAN_ORDER
Definition: StreamOps.h:29
RDKit::RDTypeTag::VecStringTag
static const boost::uint64_t VecStringTag
Definition: RDValue-doublemagic.h:109
RDKit::rdvalue_cast< float >
float rdvalue_cast< float >(RDValue_cast_t v)
Definition: RDValue-doublemagic.h:446
RDKit::DTags::BoolTag
const unsigned char BoolTag
Definition: StreamOps.h:307
RDKit::Dict::Pair
Definition: Dict.h:38
RDKit::streamWriteVec
void streamWriteVec(std::ostream &ss, const T &val)
Definition: StreamOps.h:239
RDKit::streamReadProps
unsigned int streamReadProps(std::istream &ss, RDProps &props, const CustomPropHandlerVec &handlers={})
Definition: StreamOps.h:569
RDKit::CustomPropHandler::~CustomPropHandler
virtual ~CustomPropHandler()
Definition: StreamOps.h:323
RDKit::DTags::DoubleTag
const unsigned char DoubleTag
Definition: StreamOps.h:309
RDKit::CustomPropHandler::write
virtual bool write(std::ostream &ss, const RDValue &value) const =0
RDKit::readRDStringVecValue
void readRDStringVecValue(std::istream &ss, RDValue &value)
Definition: StreamOps.h:493
RDKit::isSerializable
bool isSerializable(const Dict::Pair &pair, const CustomPropHandlerVec &handlers={})
Definition: StreamOps.h:334
export.h