NCBI C++ ToolKit
uoconv.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: uoconv.cpp 100341 2023-07-20 17:47:12Z vasilche $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Aaron Ucko
27 *
28 * File Description:
29 * Converts between User-objects and arbitrary other serializable objects.
30 *
31 * ===========================================================================
32 */
33 
34 #include <ncbi_pch.hpp>
35 
41 
42 #include <serial/objectiter.hpp>
43 
44 #if BITSTRING_AS_VECTOR
45 # include <util/resize_iter.hpp>
46 #else
47 # include <util/bitset/bmserial.h>
48 #endif
49 
50 
51 #define NCBI_USE_ERRCODE_X Objects_UOConv
52 
55 
56 typedef CUser_field::TData TUFData;
57 typedef TUFData::TOs TUFDOs;
58 
60  const string* label = 0);
61 
63 {
64 #if BITSTRING_AS_VECTOR
65  os.resize((bs.size() + CHAR_BIT - 1) / CHAR_BIT + 1);
66  // data.SetNum(bs.size());
67  os[0] = static_cast<unsigned char>(bs.size());
68  Int8 i = 1;
70  !it.AtEnd(); ++it) {
71  os[++i] = *it;
72  }
73 #else
74  CBitString::statistics st;
75  bs.calc_stat(&st);
76  os.resize(st.max_serialize_mem);
77  SIZE_TYPE n = bm::serialize(bs, reinterpret_cast<unsigned char*>(&os[0]));
78  os.resize(n);
79 #endif
80 }
81 
82 static void s_SetBSFromOS(CBitString& bs, const TUFDOs& os)
83 {
84 #if BITSTRING_AS_VECTOR
85  bs.resize(os.size() * CHAR_BIT);
86  Int8 i = 1;
88  !it.AtEnd(); ++it) {
89  *it = os[++i];
90  }
91  Int8 count = (os.size() - ((os[0] % CHAR_BIT) ? 2 : 1)) * CHAR_BIT;
92  _ASSERT( !(static_cast<unsigned char>(count) & ~os[0]) );
93  count |= os[0];
94  bs.resize(count);
95 #else
96  bm::deserialize(bs, reinterpret_cast<const unsigned char*>(&os[0]));
97 #endif
98 }
99 
101  const CAnyContentObject& obj)
102 {
103  parent.SetNumFromSize(obj.GetAttributes().size() + 4);
104 
105  parent.AddField("name", obj.GetName());
106  parent.AddField("value", obj.GetValue());
107  parent.AddField("ns_name", obj.GetNamespaceName());
108  parent.AddField("ns_prefix", obj.GetNamespacePrefix());
109 
110  ITERATE (vector<CSerialAttribInfoItem>, it, obj.GetAttributes()) {
111  parent.AddField(it->GetNamespaceName() + ":" + it->GetName(),
112  it->GetValue());
113  }
114 }
115 
117  const TUFData::TFields& fields)
118 {
119  ITERATE (TUFData::TFields, it, fields) {
120  const string& name = (*it)->GetLabel().GetStr();
121  const CStringUTF8& value = (*it)->GetData().GetStr();
122  SIZE_TYPE colon = name.find(':');
123  if (colon != NPOS) {
124  obj.AddAttribute(name.substr(colon + 1), name.substr(0, colon - 1),
125  value);
126  } else if (name == "name") {
127  obj.SetName(value);
128  } else if (name == "value") {
129  obj.SetValue(value);
130  } else if (name == "ns_name") {
131  obj.SetNamespaceName(value);
132  } else if (name == "ns_prefix") {
134  } else {
135  NCBI_THROW(CSerialException, eInvalidData,
136  "Bad User-object encoding.");
137  }
138  }
139 }
140 
142 {
143  TUFData& data = field.SetData();
144  switch (obj.GetPrimitiveValueType()) {
146  data.SetBool(true);
147  break;
148 
149  case ePrimitiveValueBool:
150  data.SetBool(obj.GetPrimitiveValueBool());
151  break;
152 
153  case ePrimitiveValueChar:
154  {
155  TUnicodeSymbol buf[1];
158  data.SetStr(CUtf8::AsUTF8(buf, 1));
159  break;
160  }
161 
163  if (obj.IsPrimitiveValueSigned()) {
164  data.SetInt(obj.GetPrimitiveValueInt());
165  } else {
166  data.SetInt(static_cast<int>(obj.GetPrimitiveValueUInt()));
167  }
168  break;
169 
170  case ePrimitiveValueReal:
171  data.SetReal(obj.GetPrimitiveValueDouble());
172  break;
173 
175  obj.GetPrimitiveValueString(data.SetStr());
176  break;
177 
178  case ePrimitiveValueEnum:
179  try {
180  obj.GetPrimitiveValueString(data.SetStr());
181  } catch (CSerialException&) {
182  data.SetInt(obj.GetPrimitiveValueInt());
183  }
184  break;
185 
187  obj.GetPrimitiveValueOctetString(data.SetOs());
188  break;
189 
191  {
192  CBitString bs;
194  s_SetOSFromBS(data.SetOs(), bs);
195  break;
196  }
197 
198  case ePrimitiveValueAny:
199  {
200  CAnyContentObject obj2;
201  obj.GetPrimitiveValueAnyContent(obj2);
202  s_SetFieldsFromAnyContent(field, obj2);
203  break;
204  }
205 
208  << "s_SetPrimitiveData: ignoring ePrimitiveValueOther");
209  break;
210  }
211 }
212 
214 {
215  size_t count;
216  try {
217  count = obj.GetContainerTypeInfo()
218  ->GetElementCount(obj.GetObjectPtr());
219  } catch (...) {
220  count = 0;
221  }
222 
223  if (count > 0) {
224  switch (obj.GetElementType().GetTypeFamily()) {
226  switch (obj.GetElementType().GetPrimitiveValueType()) {
227  case ePrimitiveValueSpecial: // can this happen?!
228  case ePrimitiveValueBool:
230  data.SetInts().reserve(count);
231  break;
232  case ePrimitiveValueChar:
234  case ePrimitiveValueEnum:
235  data.SetStrs().reserve(count);
236  break;
237  case ePrimitiveValueReal:
238  data.SetReals().reserve(count);
239  break;
242  data.SetOss().reserve(count);
243  break;
244  case ePrimitiveValueAny:
245  data.SetFields().reserve(count);
246  break;
248  ERR_POST_X(2, Warning << "s_SetContainerData:"
249  " ignoring ePrimitiveValueOther");
250  break;
251  }
252  break;
253  default:
254  data.SetFields().reserve(count);
255  break;
256  }
257  }
258 
259  count = 0;
261  it; ++it) {
262  CConstObjectInfo obj2(*it);
263  switch (obj2.GetTypeFamily()) {
265  switch (obj2.GetPrimitiveValueType()) {
266  case ePrimitiveValueSpecial: // can this happen?!
267  data.SetInts().push_back(1);
268  break;
269  case ePrimitiveValueBool:
270  data.SetInts().push_back(obj2.GetPrimitiveValueBool());
271  break;
272  case ePrimitiveValueChar:
273  data.SetStrs()
274  .push_back(CUtf8::AsUTF8(string(1, obj2.GetPrimitiveValueChar()),eEncoding_ISO8859_1));
275  break;
277  if (obj2.IsPrimitiveValueSigned()) {
278  data.SetInts().push_back(obj2.GetPrimitiveValueInt());
279  } else {
280  data.SetInts().push_back(static_cast<int>
281  (obj2.GetPrimitiveValueUInt()));
282  }
283  break;
284  case ePrimitiveValueReal:
285  data.SetReals().push_back(obj2.GetPrimitiveValueDouble());
286  break;
288  data.SetStrs().push_back(CUtf8::AsUTF8(obj2.GetPrimitiveValueString(),eEncoding_UTF8));
289  break;
290  case ePrimitiveValueEnum:
291  {
292  string s;
293  try {
294  obj2.GetPrimitiveValueString(s);
295  } catch (CSerialException&) {
297  }
298  data.SetStrs().push_back(CUtf8::AsUTF8(s,eEncoding_UTF8));
299  break;
300  }
302  {
303  TUFData::TOs* os = new TUFData::TOs;
305  data.SetOss().push_back(os);
306  break;
307  }
309  {
310  TUFData::TOs* os = new TUFData::TOs;
311  CBitString bs;
313  s_SetOSFromBS(*os, bs);
314  data.SetOss().push_back(os);
315  break;
316  }
317  case ePrimitiveValueAny:
318  {
319  CRef<CUser_field> field(new CUser_field);
320  CAnyContentObject aco;
322  s_SetFieldsFromAnyContent(*field, aco);
323  data.SetFields().push_back(field);
324  break;
325  }
327  ERR_POST_X(3, Warning << "s_SetContainerData:"
328  " ignoring ePrimitiveValueOther");
329  break;
330  }
331  break;
332 
333  case eTypeFamilyPointer:
334  {
335  CConstObjectInfo obj3 = obj2.GetPointedObject();
336  data.SetFields().push_back(s_PackAsUserField(obj3 ? obj3 : obj2));
337  break;
338  }
339 
340  default:
341  data.SetFields().push_back(s_PackAsUserField(obj2));
342  }
343  ++count;
344  }
345  return count;
346 }
347 
349 {
350  CRef<CUser_field> field(new CUser_field);
351  if (label) {
352  field->SetLabel().SetStr(*label);
353  } else {
354  field->SetLabel().SetId(0);
355  }
356 
357  TUFData& data = field->SetData();
358  switch (obj.GetTypeFamily()) {
360  s_SetPrimitiveData(*field, obj);
361  break;
362 
364  field->SetNumFromSize(s_SetContainerData(data, obj));
365  break;
366 
367  case eTypeFamilyClass:
369  it; ++it) {
370  if (it.IsSet()) {
371  if (it.GetAlias().empty() &&
372  obj.GetClassTypeInfo()->GetItems().LastIndex() == 1) {
373  // just a wrapper
374  return s_PackAsUserField(*it, label);
375  } else {
376  data.SetFields().push_back(s_PackAsUserField
377  (*it, &it.GetAlias()));
378  }
379  }
380  }
381  field->SetNumFromSize(data.GetFields().size());
382  break;
383 
384  case eTypeFamilyChoice:
385  {
387  field->SetNum(1);
388  data.SetFields().push_back(s_PackAsUserField(*var, &var.GetAlias()));
389  break;
390  }
391 
392  case eTypeFamilyPointer:
393  {
394  CConstObjectInfo obj2 = obj.GetPointedObject();
395  if (obj2) {
396  return s_PackAsUserField(obj2);
397  } else { // how to represent?
398  field->SetNum(0);
399  data.SetFields().clear();
400  }
401  break;
402  }
403  }
404 
405  return field;
406 }
407 
409 {
411  uo->SetClass(obj.GetTypeInfo()->GetModuleName());
412  uo->SetType().SetStr(obj.GetTypeInfo()->GetName());
413  uo->SetData().push_back(s_PackAsUserField(obj));
414  return uo;
415 }
416 
417 
418 static void s_UnpackUserField(const CUser_field& uo, CObjectInfo obj);
419 
421 {
422  switch (obj.GetPrimitiveValueType()) {
424  break;
425 
426  case ePrimitiveValueBool:
427  obj.SetPrimitiveValueBool(data.GetBool());
428  break;
429 
430  case ePrimitiveValueChar:
431  obj.SetPrimitiveValueChar(data.GetStr()[0]);
432  break;
433 
435  if (obj.IsPrimitiveValueSigned()) {
436  obj.SetPrimitiveValueInt(data.GetInt());
437  } else {
438  obj.SetPrimitiveValueUInt(static_cast<unsigned int>
439  (data.GetInt()));
440  }
441  break;
442 
443  case ePrimitiveValueReal:
444  obj.SetPrimitiveValueDouble(data.GetReal());
445  break;
446 
448  obj.SetPrimitiveValueString(data.GetStr());
449  break;
450 
451  case ePrimitiveValueEnum:
452  switch (data.Which()) {
453  case TUFData::e_Int:
454  obj.SetPrimitiveValueInt(data.GetInt());
455  break;
456  case TUFData::e_Str:
457  obj.SetPrimitiveValueString(data.GetStr());
458  break;
459  default:
460  NCBI_THROW(CSerialException, eInvalidData,
461  "Bad User-object encoding.");
462  }
463 
465  obj.SetPrimitiveValueOctetString(data.GetOs());
466 
468  {
469  CBitString bs;
470  s_SetBSFromOS(bs, data.GetOs());
472  }
473 
474  case ePrimitiveValueAny:
475  {
476  CAnyContentObject aco;
477  s_SetAnyContentFromFields(aco, data.GetFields());
479  }
480 
482  ERR_POST_X(4, Warning << "s_UnpackPrimitiveField:"
483  " ignoring ePrimitiveValueOther");
484  break;
485  }
486 }
487 
489 {
490  const CContainerTypeInfo* continfo = obj.GetContainerTypeInfo();
491  CObjectTypeInfo elt_oti = obj.GetElementType();
492  TTypeInfo elt_ti = elt_oti.GetTypeInfo();
493  TObjectPtr objp = obj.GetObjectPtr();
494  switch (data.Which()) {
495  case TUFData::e_Strs:
496  if (elt_oti.GetTypeFamily() != eTypeFamilyPrimitive) {
497  NCBI_THROW(CSerialException, eInvalidData,
498  "Bad User-object encoding.");
499  }
500  try {
501  continfo->ReserveElements(objp, data.GetStrs().size());
502  } catch (CSerialException&) {
503  // ignore; not implemented by all containers
504  }
505  ITERATE (TUFData::TStrs, it, data.GetStrs()) {
506  TObjectPtr p = elt_ti->Create();
507  CObjectInfo obj2(p, elt_ti, CObjectInfo::eNonCObject);
508  switch (elt_oti.GetPrimitiveValueType()) {
509  case ePrimitiveValueChar:
510  obj2.SetPrimitiveValueChar((*it)[0]);
511  break;
513  obj2.SetPrimitiveValueString(*it);
514  case ePrimitiveValueEnum:
515  try {
517  } catch (CStringException&) {
518  obj2.SetPrimitiveValueString(*it);
519  }
520  default:
521  NCBI_THROW(CSerialException, eInvalidData,
522  "Bad User-object encoding.");
523  }
524  elt_ti->Delete(p);
525  }
526  break;
527 
528  case TUFData::e_Ints:
529  if (elt_oti.GetTypeFamily() != eTypeFamilyPrimitive) {
530  NCBI_THROW(CSerialException, eInvalidData,
531  "Bad User-object encoding.");
532  }
533  try {
534  continfo->ReserveElements(objp, data.GetInts().size());
535  } catch (CSerialException&) {
536  // ignore; not implemented by all containers
537  }
538  ITERATE (TUFData::TInts, it, data.GetInts()) {
539  TObjectPtr p = elt_ti->Create();
540  CObjectInfo obj2(p, elt_ti, CObjectInfo::eNonCObject);
541  switch (elt_oti.GetPrimitiveValueType()) {
543  break;
544  case ePrimitiveValueBool:
545  obj2.SetPrimitiveValueBool(*it ? true : false);
546  break;
548  case ePrimitiveValueEnum:
549  if (obj2.IsPrimitiveValueSigned()) {
550  obj2.SetPrimitiveValueInt(*it);
551  } else {
552  obj2.SetPrimitiveValueUInt(static_cast<unsigned int>(*it));
553  }
554  break;
555  default:
556  NCBI_THROW(CSerialException, eInvalidData,
557  "Bad User-object encoding.");
558  }
559  elt_ti->Delete(p);
560  }
561  break;
562 
563  case TUFData::e_Reals:
564  if (elt_oti.GetTypeFamily() != eTypeFamilyPrimitive
565  || elt_oti.GetPrimitiveValueType() != ePrimitiveValueReal) {
566  NCBI_THROW(CSerialException, eInvalidData,
567  "Bad User-object encoding.");
568  }
569  try {
570  continfo->ReserveElements(objp, data.GetReals().size());
571  } catch (CSerialException&) {
572  // ignore; not implemented by all containers
573  }
574  ITERATE (TUFData::TReals, it, data.GetReals()) {
575  TObjectPtr p = elt_ti->Create();
576  CObjectInfo obj2(p, elt_ti, CObjectInfo::eNonCObject);
577  obj2.SetPrimitiveValueDouble(*it);
578  elt_ti->Delete(p);
579  }
580  break;
581 
582  case TUFData::e_Oss:
583  if (elt_oti.GetTypeFamily() != eTypeFamilyPrimitive) {
584  NCBI_THROW(CSerialException, eInvalidData,
585  "Bad User-object encoding.");
586  }
587  try {
588  continfo->ReserveElements(objp, data.GetOss().size());
589  } catch (CSerialException&) {
590  // ignore; not implemented by all containers
591  }
592  ITERATE (TUFData::TOss, it, data.GetOss()) {
593  TObjectPtr p = elt_ti->Create();
594  CObjectInfo obj2(p, elt_ti, CObjectInfo::eNonCObject);
595  switch (elt_oti.GetPrimitiveValueType()) {
597  obj2.SetPrimitiveValueOctetString(**it);
598  break;
599 
601  {
602  CBitString bs;
603  s_SetBSFromOS(bs, **it);
605  break;
606  }
607 
608  default:
609  NCBI_THROW(CSerialException, eInvalidData,
610  "Bad User-object encoding.");
611  }
612  elt_ti->Delete(p);
613  }
614  break;
615 
616  case TUFData::e_Fields:
617  try {
618  continfo->ReserveElements(objp, data.GetFields().size());
619  } catch (CSerialException&) {
620  // ignore; not implemented by all containers
621  }
622  ITERATE (TUFData::TFields, it, data.GetFields()) {
623  TObjectPtr p = elt_ti->Create();
624  CObjectInfo obj2(p, elt_ti);
625  s_UnpackUserField(**it, obj2);
626  if ( !elt_ti->IsCObject() ) {
627  elt_ti->Delete(p);
628  }
629  }
630  break;
631 
632  default:
633  break;
634  }
635 }
636 
637 static void s_UnpackUserField(const CUser_field& field, CObjectInfo obj)
638 {
639  _ASSERT(obj && obj.GetObjectPtr());
640  const TUFData& data = field.GetData();
641  switch (obj.GetTypeFamily()) {
644  break;
645 
648  break;
649 
650  case eTypeFamilyClass:
651  ITERATE (TUFData::TFields, it, data.GetFields()) {
652  if ((*it)->GetLabel().IsStr()) {
653  string name = (*it)->GetLabel().GetStr();
655  = obj.FindClassMember(NStr::ToLower(name));
656  // make sure there actually *is* such a field?
657  if (mi.IsSet()) {
658  // complain! (dup, presumably...)
659  }
660  s_UnpackUserField(**it, *mi);
661  } else {
662  // complain!
663  }
664  }
665  // make sure we got all mandatory fields
666  break;
667 
668  case eTypeFamilyChoice:
669  if (data.GetFields().size() == 1) {
670  const CUser_field& field2 = *data.GetFields().front();
671  TMemberIndex index;
672  switch (field2.GetLabel().Which()) {
673  case CObject_id::e_Str:
674  {
675  string name = field2.GetLabel().GetStr();
676  index = obj.FindVariantIndex(NStr::ToLower(name));
677  break;
678  }
679  case CObject_id::e_Id:
680  index = obj.FindVariantIndex(field.GetLabel().GetId());
681  break;
682  default:
683  index = kInvalidMember;
684  break;
685  }
686  // make sure index is valid?
687  obj.GetChoiceTypeInfo()->SetIndex(obj.GetObjectPtr(), index);
689  } else {
690  // complain!
691  }
692  break;
693 
694  case eTypeFamilyPointer:
695  // initialize pointer if NULL?
696  s_UnpackUserField(field, obj.GetPointedObject());
697  break;
698  }
699 }
700 
701 
703 {
704  _ASSERT(obj && obj.GetObjectPtr());
705  s_UnpackUserField(*uo.GetData().front(), obj);
706 }
707 
709 {
710  _ASSERT(ti);
711  CObjectInfo obj(ti);
712  UnpackUserObject(uo, obj);
713  return obj;
714 }
715 
716 
#define static
Serialization / compression of bvector<>. Set theoretical operations on compressed BLOBs.
Serializable object that stores any combination of parsable data.
Definition: serialbase.hpp:264
CConstObjectInfoCV –.
Definition: objectiter.hpp:557
CConstObjectInfoEI –.
Definition: objectiter.hpp:56
CConstObjectInfoMI –.
Definition: objectiter.hpp:397
CConstObjectInfo –.
Definition: objectinfo.hpp:421
CObjectInfoMI –.
Definition: objectiter.hpp:432
CObjectInfo –.
Definition: objectinfo.hpp:597
CObjectTypeInfo –.
Definition: objectinfo.hpp:94
CRef –.
Definition: ncbiobj.hpp:618
Root class for all serialization exceptions.
Definition: exception.hpp:50
CStringException –.
Definition: ncbistr.hpp:4506
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
void SetNumFromSize(size_t value)
Set num field from a container size Check for overflow and throw CSerialException::eOverflow if the s...
Definition: User_field.cpp:492
CUser_field & AddField(const string &label, int value)
add fields to the current user field
Definition: User_field.cpp:92
void resize(size_type new_size)
Change size of the bvector.
Definition: bm.h:2463
char data[12]
Definition: iconv.c:80
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
TMemberIndex LastIndex(void) const
Definition: memberlist.hpp:82
void * TObjectPtr
Definition: serialdef.hpp:55
const CStringUTF8 & GetValue(void) const
Get normalized value.
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
const string & GetNamespaceName(void) const
Get namespace name.
const TMemberIndex kInvalidMember
Special value returned from FindMember.
Definition: serialdef.hpp:237
void SetName(const string &name)
Set local name.
void AddAttribute(const string &name, const string &ns_name, const CStringUTF8 &value)
Add attribute.
void SetNamespacePrefix(const string &ns_prefix)
Set namespace prefix.
const string & GetNamespacePrefix(void) const
Get namespace prefix.
void SetNamespaceName(const string &ns_name)
Set namespace name.
const string & GetName(void) const
Get local name.
void SetValue(const CStringUTF8 &value)
Set normalized value.
const vector< CSerialAttribInfoItem > & GetAttributes(void) const
Get object attributes.
@ ePrimitiveValueSpecial
null, void
Definition: serialdef.hpp:148
@ ePrimitiveValueOctetString
vector<(signed|unsigned)? char>
Definition: serialdef.hpp:155
@ ePrimitiveValueString
string|char*|const char*
Definition: serialdef.hpp:153
@ ePrimitiveValueOther
Definition: serialdef.hpp:161
@ ePrimitiveValueInteger
(signed|unsigned) (char|short|int|long)
Definition: serialdef.hpp:151
@ ePrimitiveValueAny
Definition: serialdef.hpp:160
@ ePrimitiveValueChar
char
Definition: serialdef.hpp:150
@ ePrimitiveValueBool
bool
Definition: serialdef.hpp:149
@ ePrimitiveValueEnum
enum
Definition: serialdef.hpp:154
@ ePrimitiveValueReal
float|double
Definition: serialdef.hpp:152
@ ePrimitiveValueBitString
Definition: serialdef.hpp:156
@ eTypeFamilyClass
Definition: serialdef.hpp:140
@ eTypeFamilyContainer
Definition: serialdef.hpp:142
@ eTypeFamilyChoice
Definition: serialdef.hpp:141
@ eTypeFamilyPointer
Definition: serialdef.hpp:143
@ eTypeFamilyPrimitive
Definition: serialdef.hpp:139
const string & GetAlias(void) const
void SetPrimitiveValueChar(char value)
Definition: objectinfo.cpp:232
void GetPrimitiveValueBitString(CBitString &value) const
Get bit string data.
Definition: objectinfo.cpp:216
TMemberIndex FindVariantIndex(const string &name) const
Find choice variant index by its name.
Definition: objectinfo.cpp:134
CConstObjectInfo GetPointedObject(void) const
Get data and type information of object to which this type refers.
Definition: objectinfo.cpp:96
CObjectInfo GetPointedObject(void) const
Get data and type information of object to which this type refers.
Definition: objectinfo.cpp:102
bool GetPrimitiveValueBool(void) const
Get boolean data.
Definition: objectinfo.cpp:144
void GetPrimitiveValueOctetString(vector< char > &value) const
Get octet string data.
Definition: objectinfo.cpp:211
TObjectPtr GetObjectPtr(void) const
Get pointer to object.
void SetPrimitiveValueString(const string &value)
Definition: objectinfo.cpp:282
void SetPrimitiveValueBool(bool value)
Set boolean data.
Definition: objectinfo.cpp:227
CChoiceVariant GetCurrentChoiceVariant(void) const
Get data and type information of selected choice variant.
CChoiceVariant GetCurrentChoiceVariant(void) const
Get data and type information of selected choice variant.
TTypeInfo GetTypeInfo(void) const
int GetPrimitiveValueInt(void) const
Get data as int.
Definition: objectinfo.cpp:154
const CChoiceTypeInfo * GetChoiceTypeInfo(void) const
Definition: objectinfo.cpp:67
const CClassTypeInfo * GetClassTypeInfo(void) const
Definition: objectinfo.cpp:61
char GetPrimitiveValueChar(void) const
Get char data.
Definition: objectinfo.cpp:149
void SetPrimitiveValueUInt(unsigned value)
Definition: objectinfo.cpp:262
void SetPrimitiveValueBitString(const CBitString &value)
Definition: objectinfo.cpp:292
void GetPrimitiveValueAnyContent(CAnyContentObject &value) const
Get data as CAnyContentObject.
Definition: objectinfo.cpp:221
CMemberIterator BeginMembers(void) const
Create class member iterator.
ETypeFamily GetTypeFamily(void) const
Get data type family.
void GetPrimitiveValueString(string &value) const
Get string data.
Definition: objectinfo.cpp:199
double GetPrimitiveValueDouble(void) const
Get data as double.
Definition: objectinfo.cpp:194
CMemberIterator FindClassMember(const string &memberName) const
Find class member by its name.
void SetPrimitiveValueAnyContent(const CAnyContentObject &value)
Definition: objectinfo.cpp:297
CElementIterator BeginElements(void) const
Create container elements iterator.
void SetPrimitiveValueDouble(double value)
Definition: objectinfo.cpp:277
TConstObjectPtr GetObjectPtr(void) const
Get pointer to object.
void SetPrimitiveValueInt(int value)
Definition: objectinfo.cpp:257
void SetPrimitiveValueOctetString(const vector< char > &value)
Definition: objectinfo.cpp:287
const CContainerTypeInfo * GetContainerTypeInfo(void) const
Definition: objectinfo.cpp:73
EPrimitiveValueType GetPrimitiveValueType(void) const
Get type of primitive value.
Definition: objectinfo.cpp:109
unsigned GetPrimitiveValueUInt(void) const
Get data as unsigned int.
Definition: objectinfo.cpp:159
bool IsSet(void) const
Is member assigned a value.
bool IsPrimitiveValueSigned(void) const
Is primitive value signed.
Definition: objectinfo.cpp:114
CObjectTypeInfo GetElementType(void) const
Get type information of an element of container.
Definition: objectinfo.cpp:85
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
#define CHAR_BIT
bool AtEnd() const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
std::string CStringUTF8
Definition: ncbistl.hpp:254
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
#define NPOS
Definition: ncbistr.hpp:133
Uint4 TUnicodeSymbol
Unicode character.
Definition: ncbistr.hpp:141
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
Definition: ncbistr.hpp:3889
static TUnicodeSymbol CharToSymbol(char ch, EEncoding encoding)
Convert encoded character into Unicode.
Definition: ncbistr.cpp:6839
static string & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
@ eEncoding_ISO8859_1
Note: From the point of view of the C++.
Definition: ncbistr.hpp:203
@ eEncoding_UTF8
Definition: ncbistr.hpp:201
const string & GetName(void) const
Get name of this type.
Definition: typeinfo.cpp:249
virtual const string & GetModuleName(void) const
Get module name.
Definition: typeinfo.cpp:254
const CItemsInfo & GetItems(void) const
size_t GetElementCount(TConstObjectPtr containerPtr) const
void ReserveElements(TObjectPtr containerPtr, size_t new_count) const
bool IsCObject(void) const
Check is this TypeInfo object is kind of CClassTypeInfoBase.
TObjectPtr Create(CObjectMemoryPool *memoryPool=0) const
Create object of this type on heap (can be deleted by operator delete)
void SetIndex(TObjectPtr object, TMemberIndex index, CObjectMemoryPool *pool=0) const
virtual void Delete(TObjectPtr object) const
Delete object.
Definition: typeinfo.cpp:299
static const char label[]
size_t serialize(const BV &bv, unsigned char *buf, bm::word_t *temp_block=0, unsigned serialization_flags=0)
Saves bitvector into memory.
Definition: bmserial.h:3071
size_t deserialize(BV &bv, const unsigned char *buf, bm::word_t *temp_block=0, const bm::bv_ref_vector< BV > *ref_vect=0)
Bitvector deserialization from a memory BLOB.
Definition: bmserial.h:3137
const TData & GetData(void) const
Get the Data member data.
vector< double > TReals
vector< CRef< CUser_field > > TFields
vector< vector< char > * > TOss
E_Choice Which(void) const
Which variant is currently selected.
Definition: Object_id_.hpp:235
void SetClass(const TClass &value)
Assign a value to Class data member.
TData & SetData(void)
Assign a value to Data data member.
void SetNum(TNum value)
Assign a value to Num data member.
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
void SetLabel(TLabel &value)
Assign a value to Label data member.
const TData & GetData(void) const
Get the Data member data.
void SetType(TType &value)
Assign a value to Type data member.
void SetData(TData &value)
Assign a value to Data data member.
const TLabel & GetLabel(void) const
Get the Label member data.
vector< CStringUTF8 > TStrs
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
Definition of all error codes used in objects libraries.
char * buf
int i
yy_size_t n
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define _ASSERT
static void s_UnpackContainerField(const TUFData &data, CObjectInfo obj)
Definition: uoconv.cpp:488
static void s_UnpackUserField(const CUser_field &uo, CObjectInfo obj)
Definition: uoconv.cpp:637
static void s_SetOSFromBS(TUFDOs &os, CBitString &bs)
Definition: uoconv.cpp:62
static size_t s_SetContainerData(TUFData &data, CConstObjectInfo obj)
Definition: uoconv.cpp:213
static CRef< CUser_field > s_PackAsUserField(CConstObjectInfo obj, const string *label=0)
Definition: uoconv.cpp:348
void UnpackUserObject(const CUser_object &uo, CObjectInfo obj)
Definition: uoconv.cpp:702
TUFData::TOs TUFDOs
Definition: uoconv.cpp:57
CRef< CUser_object > PackAsUserObject(CConstObjectInfo obj)
Definition: uoconv.cpp:408
static void s_UnpackPrimitiveField(const TUFData &data, CObjectInfo obj)
Definition: uoconv.cpp:420
static void s_SetAnyContentFromFields(CAnyContentObject &obj, const TUFData::TFields &fields)
Definition: uoconv.cpp:116
static void s_SetFieldsFromAnyContent(CUser_field &parent, const CAnyContentObject &obj)
Definition: uoconv.cpp:100
static void s_SetBSFromOS(CBitString &bs, const TUFDOs &os)
Definition: uoconv.cpp:82
static void s_SetPrimitiveData(CUser_field &field, CConstObjectInfo obj)
Definition: uoconv.cpp:141
Converts between User-objects and arbitrary other serializable objects.
#define const
Definition: zconf.h:232
Modified on Sat May 25 14:20:48 2024 by modify_doxy.py rev. 669887