1 /* $Id: typeinfo.cpp 586652 2019-05-20 18:09:55Z gouriano $
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: Eugene Vasilchenko
27 *
28 * File Description:
29 * !!! PUT YOUR DESCRIPTION HERE !!!
30 *
31 * ===========================================================================
32 */
33
34 #include <ncbi_pch.hpp>
35 #include <corelib/ncbithr.hpp>
36 #include <serial/typeinfo.hpp>
37 #include <serial/impl/typeinfoimpl.hpp>
38 #include <serial/objistr.hpp>
39 #include <serial/objostr.hpp>
40 #include <serial/objcopy.hpp>
41 #include <serial/serialimpl.hpp>
42 #include <corelib/ncbimtx.hpp>
43
44 BEGIN_NCBI_SCOPE
45
46 /* put back inside GetTypeInfoMutex when Mac CodeWarrior 9 comes out */
47 DEFINE_STATIC_MUTEX(s_TypeInfoMutex);
48
GetTypeInfoMutex(void)49 SSystemMutex& GetTypeInfoMutex(void)
50 {
51 return s_TypeInfoMutex;
52 }
GetTypeInfoLock(void)53 CRWLock& GetTypeInfoLock(void)
54 {
55 static CRWLock s_TypeInfoLock;
56 return s_TypeInfoLock;
57 }
58
59
60 class CTypeInfoFunctions
61 {
62 public:
63 static void ReadWithHook(CObjectIStream& in,
64 TTypeInfo objectType, TObjectPtr objectPtr);
65 static void WriteWithHook(CObjectOStream& out,
66 TTypeInfo objectType, TConstObjectPtr objectPtr);
67 static void SkipWithHook(CObjectIStream& stream,
68 TTypeInfo objectType);
69 static void CopyWithHook(CObjectStreamCopier& copier,
70 TTypeInfo objectType);
71 };
72
73 class CNamespaceInfoItem
74 {
75 public:
76 CNamespaceInfoItem(void);
77 CNamespaceInfoItem(const CNamespaceInfoItem& other);
78 virtual ~CNamespaceInfoItem(void);
79
80 bool HasNamespaceName(void) const;
81 const string& GetNamespaceName(void) const;
82 void SetNamespaceName(const string& ns_name);
83
84 bool HasNamespacePrefix(void) const;
85 const string& GetNamespacePrefix(void) const;
86 void SetNamespacePrefix(const string& ns_prefix);
87
88 ENsQualifiedMode IsNsQualified(void);
89 void SetNsQualified(bool qualified);
90
91 private:
92 string m_NsName;
93 string m_NsPrefix;
94 bool m_NsPrefixSet;
95 ENsQualifiedMode m_NsQualified;
96 };
97
98 typedef CTypeInfoFunctions TFunc;
99
CTypeInfo(ETypeFamily typeFamily,size_t size)100 CTypeInfo::CTypeInfo(ETypeFamily typeFamily, size_t size)
101 : m_TypeFamily(typeFamily), m_Size(size), m_Name(),
102 m_InfoItem(0),
103 m_CodeVer(0),
104 m_DataSpec(EDataSpec::eUnknown),
105 m_IsCObject(false),
106 m_IsInternal(false),
107 m_Tag(eNoExplicitTag), m_TagClass(CAsnBinaryDefs::eUniversal),
108 m_TagType(CAsnBinaryDefs::eAutomatic),
109 m_TagConstructed(CAsnBinaryDefs::eConstructed),
110 m_CSerialUserOp(eTriState_Unknown),
111 m_CreateFunction(&CVoidTypeFunctions::Create),
112 m_ReadHookData(&CVoidTypeFunctions::Read, &TFunc::ReadWithHook),
113 m_WriteHookData(&CVoidTypeFunctions::Write, &TFunc::WriteWithHook),
114 m_SkipHookData(&CVoidTypeFunctions::Skip, &TFunc::SkipWithHook),
115 m_CopyHookData(&CVoidTypeFunctions::Copy, &TFunc::CopyWithHook)
116
117 {
118 return;
119 }
120
121
CTypeInfo(ETypeFamily typeFamily,size_t size,const char * name)122 CTypeInfo::CTypeInfo(ETypeFamily typeFamily, size_t size, const char* name)
123 : m_TypeFamily(typeFamily), m_Size(size), m_Name(name),
124 m_InfoItem(0),
125 m_CodeVer(0),
126 m_DataSpec(EDataSpec::eUnknown),
127 m_IsCObject(false),
128 m_IsInternal(false),
129 m_Tag(eNoExplicitTag), m_TagClass(CAsnBinaryDefs::eUniversal),
130 m_TagType(CAsnBinaryDefs::eAutomatic),
131 m_TagConstructed(CAsnBinaryDefs::eConstructed),
132 m_CSerialUserOp(eTriState_Unknown),
133 m_CreateFunction(&CVoidTypeFunctions::Create),
134 m_ReadHookData(&CVoidTypeFunctions::Read, &TFunc::ReadWithHook),
135 m_WriteHookData(&CVoidTypeFunctions::Write, &TFunc::WriteWithHook),
136 m_SkipHookData(&CVoidTypeFunctions::Skip, &TFunc::SkipWithHook),
137 m_CopyHookData(&CVoidTypeFunctions::Copy, &TFunc::CopyWithHook)
138 {
139 return;
140 }
141
142
CTypeInfo(ETypeFamily typeFamily,size_t size,const string & name)143 CTypeInfo::CTypeInfo(ETypeFamily typeFamily, size_t size, const string& name)
144 : m_TypeFamily(typeFamily), m_Size(size), m_Name(name),
145 m_InfoItem(0),
146 m_CodeVer(0),
147 m_DataSpec(EDataSpec::eUnknown),
148 m_IsCObject(false),
149 m_IsInternal(false),
150 m_Tag(eNoExplicitTag), m_TagClass(CAsnBinaryDefs::eUniversal),
151 m_TagType(CAsnBinaryDefs::eAutomatic),
152 m_TagConstructed(CAsnBinaryDefs::eConstructed),
153 m_CSerialUserOp(eTriState_Unknown),
154 m_CreateFunction(&CVoidTypeFunctions::Create),
155 m_ReadHookData(&CVoidTypeFunctions::Read, &TFunc::ReadWithHook),
156 m_WriteHookData(&CVoidTypeFunctions::Write, &TFunc::WriteWithHook),
157 m_SkipHookData(&CVoidTypeFunctions::Skip, &TFunc::SkipWithHook),
158 m_CopyHookData(&CVoidTypeFunctions::Copy, &TFunc::CopyWithHook)
159 {
160 return;
161 }
162
163
~CTypeInfo(void)164 CTypeInfo::~CTypeInfo(void)
165 {
166 if (m_InfoItem) {
167 delete m_InfoItem;
168 }
169 return;
170 }
171
SetTag(CAsnBinaryDefs::TLongTag tag,CAsnBinaryDefs::ETagClass tagclass,CAsnBinaryDefs::ETagType tagtype)172 CTypeInfo* CTypeInfo::SetTag(
173 CAsnBinaryDefs::TLongTag tag,
174 CAsnBinaryDefs::ETagClass tagclass, CAsnBinaryDefs::ETagType tagtype)
175 {
176 m_Tag = tag;
177 m_TagClass = tagclass;
178 m_TagType = tagtype;
179 return this;
180 }
181
DataSpec(EDataSpec spec)182 void CTypeInfo::DataSpec(EDataSpec spec)
183 {
184 m_DataSpec = spec;
185 }
186
HasNamespaceName(void) const187 bool CTypeInfo::HasNamespaceName(void) const
188 {
189 return m_InfoItem ? m_InfoItem->HasNamespaceName() : false;
190 }
191
GetNamespaceName(void) const192 const string& CTypeInfo::GetNamespaceName(void) const
193 {
194 return m_InfoItem ? m_InfoItem->GetNamespaceName() : kEmptyStr;
195 }
196
SetNamespaceName(const string & ns_name) const197 const CTypeInfo* CTypeInfo::SetNamespaceName(const string& ns_name) const
198 {
199 x_CreateInfoItemIfNeeded();
200 m_InfoItem->SetNamespaceName(ns_name);
201 return this;
202 }
203
SetNsQualified(bool qualified) const204 const CTypeInfo* CTypeInfo::SetNsQualified(bool qualified) const
205 {
206 _ASSERT(m_InfoItem);
207 m_InfoItem->SetNsQualified(qualified);
208 return this;
209 }
210
IsNsQualified(void) const211 ENsQualifiedMode CTypeInfo::IsNsQualified(void) const
212 {
213 return m_InfoItem ? m_InfoItem->IsNsQualified() : eNSQNotSet;
214 }
215
HasNamespacePrefix(void) const216 bool CTypeInfo::HasNamespacePrefix(void) const
217 {
218 return m_InfoItem ? m_InfoItem->HasNamespacePrefix() : false;
219 }
220
GetNamespacePrefix(void) const221 const string& CTypeInfo::GetNamespacePrefix(void) const
222 {
223 return m_InfoItem ? m_InfoItem->GetNamespacePrefix() : kEmptyStr;
224 }
225
SetNamespacePrefix(const string & ns_prefix) const226 void CTypeInfo::SetNamespacePrefix(const string& ns_prefix) const
227 {
228 x_CreateInfoItemIfNeeded();
229 m_InfoItem->SetNamespacePrefix(ns_prefix);
230 }
231
x_CreateInfoItemIfNeeded(void) const232 void CTypeInfo::x_CreateInfoItemIfNeeded(void) const
233 {
234 if (!m_InfoItem) {
235 m_InfoItem = new CNamespaceInfoItem;
236 }
237 }
238
CopyInfoItem(TTypeInfo other)239 void CTypeInfo::CopyInfoItem(TTypeInfo other)
240 {
241 if (other->m_InfoItem) {
242 if (m_InfoItem) {
243 delete m_InfoItem;
244 }
245 m_InfoItem = new CNamespaceInfoItem(*(other->m_InfoItem));
246 }
247 }
248
GetName(void) const249 const string& CTypeInfo::GetName(void) const
250 {
251 return IsInternal()? kEmptyStr: m_Name;
252 }
253
GetModuleName(void) const254 const string& CTypeInfo::GetModuleName(void) const
255 {
256 return IsInternal()? kEmptyStr: m_ModuleName;
257 }
258
SetModuleName(const string & name)259 void CTypeInfo::SetModuleName(const string& name)
260 {
261 if ( !m_ModuleName.empty() )
262 NCBI_THROW(CSerialException,eFail, "cannot change module name");
263 m_ModuleName = name;
264 }
265
SetModuleName(const char * name)266 void CTypeInfo::SetModuleName(const char* name)
267 {
268 SetModuleName(string(name));
269 }
270
GetInternalName(void) const271 const string& CTypeInfo::GetInternalName(void) const
272 {
273 return !IsInternal()? kEmptyStr: m_Name;
274 }
275
GetInternalModuleName(void) const276 const string& CTypeInfo::GetInternalModuleName(void) const
277 {
278 return !IsInternal()? kEmptyStr: m_ModuleName;
279 }
280
SetInternalName(const string & name)281 void CTypeInfo::SetInternalName(const string& name)
282 {
283 if ( IsInternal() || !m_Name.empty() || !m_ModuleName.empty() )
284 NCBI_THROW(CSerialException,eFail, "cannot change (internal) name");
285 m_IsInternal = true;
286 m_Name = name;
287 }
288
GetAccessName(void) const289 const string& CTypeInfo::GetAccessName(void) const
290 {
291 return m_Name;
292 }
293
GetAccessModuleName(void) const294 const string& CTypeInfo::GetAccessModuleName(void) const
295 {
296 return m_ModuleName;
297 }
298
Delete(TObjectPtr) const299 void CTypeInfo::Delete(TObjectPtr /*object*/) const
300 {
301 NCBI_THROW(CSerialException,eIllegalCall,
302 "This type cannot be allocated on heap");
303 }
304
DeleteExternalObjects(TObjectPtr) const305 void CTypeInfo::DeleteExternalObjects(TObjectPtr /*object*/) const
306 {
307 }
308
GetRealTypeInfo(TConstObjectPtr) const309 TTypeInfo CTypeInfo::GetRealTypeInfo(TConstObjectPtr ) const
310 {
311 return this;
312 }
313
IsType(TTypeInfo typeInfo) const314 bool CTypeInfo::IsType(TTypeInfo typeInfo) const
315 {
316 return this == typeInfo;
317 }
318
319 CTypeInfo::EMayContainType
GetMayContainType(TTypeInfo) const320 CTypeInfo::GetMayContainType(TTypeInfo /*typeInfo*/) const
321 {
322 return eMayContainType_no;
323 }
324
GetCObjectPtr(TConstObjectPtr) const325 const CObject* CTypeInfo::GetCObjectPtr(TConstObjectPtr /*objectPtr*/) const
326 {
327 return 0;
328 }
329
IsParentClassOf(const CClassTypeInfo *) const330 bool CTypeInfo::IsParentClassOf(const CClassTypeInfo* /*classInfo*/) const
331 {
332 return false;
333 }
334
AsCSerialUserOp(TConstObjectPtr obj) const335 const CSerialUserOp* CTypeInfo::AsCSerialUserOp(TConstObjectPtr obj) const
336 {
337 if (IsCObject() && m_CSerialUserOp != eTriState_False) {
338 const CSerialUserOp* op = dynamic_cast<const CSerialUserOp*>( static_cast<const CObject*>(obj));
339 m_CSerialUserOp = (op != nullptr) ? eTriState_True : eTriState_False;
340 return op;
341 }
342 return nullptr;
343 }
344
AsCSerialUserOp(TObjectPtr obj) const345 CSerialUserOp* CTypeInfo::AsCSerialUserOp(TObjectPtr obj) const
346 {
347 if (IsCObject() && m_CSerialUserOp != eTriState_False) {
348 CSerialUserOp* op = dynamic_cast<CSerialUserOp*>( static_cast<CObject*>(obj));
349 m_CSerialUserOp = (op != nullptr) ? eTriState_True : eTriState_False;
350 return op;
351 }
352 return nullptr;
353 }
354
SetCreateFunction(TTypeCreate func)355 void CTypeInfo::SetCreateFunction(TTypeCreate func)
356 {
357 m_CreateFunction = func;
358 }
359
SetLocalReadHook(CObjectIStream & stream,CReadObjectHook * hook)360 void CTypeInfo::SetLocalReadHook(CObjectIStream& stream,
361 CReadObjectHook* hook)
362 {
363 XSERIAL_TYPEINFO_WRITELOCK;
364 m_ReadHookData.SetLocalHook(stream.m_ObjectHookKey, hook);
365 }
366
SetGlobalReadHook(CReadObjectHook * hook)367 void CTypeInfo::SetGlobalReadHook(CReadObjectHook* hook)
368 {
369 XSERIAL_TYPEINFO_WRITELOCK;
370 m_ReadHookData.SetGlobalHook(hook);
371 }
372
ResetLocalReadHook(CObjectIStream & stream)373 void CTypeInfo::ResetLocalReadHook(CObjectIStream& stream)
374 {
375 XSERIAL_TYPEINFO_WRITELOCK;
376 m_ReadHookData.ResetLocalHook(stream.m_ObjectHookKey);
377 }
378
ResetGlobalReadHook(void)379 void CTypeInfo::ResetGlobalReadHook(void)
380 {
381 XSERIAL_TYPEINFO_WRITELOCK;
382 m_ReadHookData.ResetGlobalHook();
383 }
384
SetPathReadHook(CObjectIStream * in,const string & path,CReadObjectHook * hook)385 void CTypeInfo::SetPathReadHook(CObjectIStream* in, const string& path,
386 CReadObjectHook* hook)
387 {
388 XSERIAL_TYPEINFO_WRITELOCK;
389 m_ReadHookData.SetPathHook(in,path,hook);
390 }
391
SetGlobalWriteHook(CWriteObjectHook * hook)392 void CTypeInfo::SetGlobalWriteHook(CWriteObjectHook* hook)
393 {
394 XSERIAL_TYPEINFO_WRITELOCK;
395 m_WriteHookData.SetGlobalHook(hook);
396 }
397
SetLocalWriteHook(CObjectOStream & stream,CWriteObjectHook * hook)398 void CTypeInfo::SetLocalWriteHook(CObjectOStream& stream,
399 CWriteObjectHook* hook)
400 {
401 XSERIAL_TYPEINFO_WRITELOCK;
402 m_WriteHookData.SetLocalHook(stream.m_ObjectHookKey, hook);
403 }
404
ResetGlobalWriteHook(void)405 void CTypeInfo::ResetGlobalWriteHook(void)
406 {
407 XSERIAL_TYPEINFO_WRITELOCK;
408 m_WriteHookData.ResetGlobalHook();
409 }
410
ResetLocalWriteHook(CObjectOStream & stream)411 void CTypeInfo::ResetLocalWriteHook(CObjectOStream& stream)
412 {
413 XSERIAL_TYPEINFO_WRITELOCK;
414 m_WriteHookData.ResetLocalHook(stream.m_ObjectHookKey);
415 }
416
SetPathWriteHook(CObjectOStream * out,const string & path,CWriteObjectHook * hook)417 void CTypeInfo::SetPathWriteHook(CObjectOStream* out, const string& path,
418 CWriteObjectHook* hook)
419 {
420 XSERIAL_TYPEINFO_WRITELOCK;
421 m_WriteHookData.SetPathHook(out,path,hook);
422 }
423
SetLocalSkipHook(CObjectIStream & stream,CSkipObjectHook * hook)424 void CTypeInfo::SetLocalSkipHook(CObjectIStream& stream,
425 CSkipObjectHook* hook)
426 {
427 XSERIAL_TYPEINFO_WRITELOCK;
428 m_SkipHookData.SetLocalHook(stream.m_ObjectSkipHookKey, hook);
429 stream.AddMonitorType(this);
430 }
431
ResetLocalSkipHook(CObjectIStream & stream)432 void CTypeInfo::ResetLocalSkipHook(CObjectIStream& stream)
433 {
434 XSERIAL_TYPEINFO_WRITELOCK;
435 m_SkipHookData.ResetLocalHook(stream.m_ObjectSkipHookKey);
436 }
437
SetPathSkipHook(CObjectIStream * in,const string & path,CSkipObjectHook * hook)438 void CTypeInfo::SetPathSkipHook(CObjectIStream* in, const string& path,
439 CSkipObjectHook* hook)
440 {
441 XSERIAL_TYPEINFO_WRITELOCK;
442 m_SkipHookData.SetPathHook(in,path,hook);
443 }
444
SetGlobalCopyHook(CCopyObjectHook * hook)445 void CTypeInfo::SetGlobalCopyHook(CCopyObjectHook* hook)
446 {
447 XSERIAL_TYPEINFO_WRITELOCK;
448 m_CopyHookData.SetGlobalHook(hook);
449 }
450
SetLocalCopyHook(CObjectStreamCopier & stream,CCopyObjectHook * hook)451 void CTypeInfo::SetLocalCopyHook(CObjectStreamCopier& stream,
452 CCopyObjectHook* hook)
453 {
454 XSERIAL_TYPEINFO_WRITELOCK;
455 m_CopyHookData.SetLocalHook(stream.m_ObjectHookKey, hook);
456 }
457
ResetGlobalCopyHook(void)458 void CTypeInfo::ResetGlobalCopyHook(void)
459 {
460 XSERIAL_TYPEINFO_WRITELOCK;
461 m_CopyHookData.ResetGlobalHook();
462 }
463
ResetLocalCopyHook(CObjectStreamCopier & stream)464 void CTypeInfo::ResetLocalCopyHook(CObjectStreamCopier& stream)
465 {
466 XSERIAL_TYPEINFO_WRITELOCK;
467 m_CopyHookData.ResetLocalHook(stream.m_ObjectHookKey);
468 }
469
SetPathCopyHook(CObjectStreamCopier * copier,const string & path,CCopyObjectHook * hook)470 void CTypeInfo::SetPathCopyHook(CObjectStreamCopier* copier, const string& path,
471 CCopyObjectHook* hook)
472 {
473 XSERIAL_TYPEINFO_WRITELOCK;
474 m_CopyHookData.SetPathHook(copier ? &(copier->In()) : 0,path,hook);
475 }
476
SetReadFunction(TTypeReadFunction func)477 void CTypeInfo::SetReadFunction(TTypeReadFunction func)
478 {
479 m_ReadHookData.SetDefaultFunction(func);
480 }
481
GetReadFunction(void) const482 TTypeReadFunction CTypeInfo::GetReadFunction(void) const
483 {
484 return m_ReadHookData.GetDefaultFunction();
485 }
486
SetWriteFunction(TTypeWriteFunction func)487 void CTypeInfo::SetWriteFunction(TTypeWriteFunction func)
488 {
489 m_WriteHookData.SetDefaultFunction(func);
490 }
491
SetCopyFunction(TTypeCopyFunction func)492 void CTypeInfo::SetCopyFunction(TTypeCopyFunction func)
493 {
494 m_CopyHookData.SetDefaultFunction(func);
495 }
496
SetSkipFunction(TTypeSkipFunction func)497 void CTypeInfo::SetSkipFunction(TTypeSkipFunction func)
498 {
499 m_SkipHookData.SetDefaultFunction(func);
500 }
501
ReadWithHook(CObjectIStream & stream,TTypeInfo objectType,TObjectPtr objectPtr)502 void CTypeInfoFunctions::ReadWithHook(CObjectIStream& stream,
503 TTypeInfo objectType,
504 TObjectPtr objectPtr)
505 {
506 CReadObjectHook* hook =
507 objectType->m_ReadHookData.GetHook(stream.m_ObjectHookKey);
508 if (!hook) {
509 hook = objectType->m_ReadHookData.GetPathHook(stream);
510 }
511 if ( hook )
512 hook->ReadObject(stream, CObjectInfo(objectPtr, objectType));
513 else
514 objectType->DefaultReadData(stream, objectPtr);
515 }
516
WriteWithHook(CObjectOStream & stream,TTypeInfo objectType,TConstObjectPtr objectPtr)517 void CTypeInfoFunctions::WriteWithHook(CObjectOStream& stream,
518 TTypeInfo objectType,
519 TConstObjectPtr objectPtr)
520 {
521 CWriteObjectHook* hook =
522 objectType->m_WriteHookData.GetHook(stream.m_ObjectHookKey);
523 if (!hook) {
524 hook = objectType->m_WriteHookData.GetPathHook(stream);
525 }
526 if ( hook )
527 hook->WriteObject(stream, CConstObjectInfo(objectPtr, objectType));
528 else
529 objectType->DefaultWriteData(stream, objectPtr);
530 }
531
SkipWithHook(CObjectIStream & stream,TTypeInfo objectType)532 void CTypeInfoFunctions::SkipWithHook(CObjectIStream& stream,
533 TTypeInfo objectType)
534 {
535 CSkipObjectHook* hook =
536 objectType->m_SkipHookData.GetHook(stream.m_ObjectSkipHookKey);
537 if (!hook) {
538 hook = objectType->m_SkipHookData.GetPathHook(stream);
539 }
540 if ( hook )
541 hook->SkipObject(stream, objectType);
542 else
543 objectType->DefaultSkipData(stream);
544 }
545
CopyWithHook(CObjectStreamCopier & stream,TTypeInfo objectType)546 void CTypeInfoFunctions::CopyWithHook(CObjectStreamCopier& stream,
547 TTypeInfo objectType)
548 {
549 CCopyObjectHook* hook =
550 objectType->m_CopyHookData.GetHook(stream.m_ObjectHookKey);
551 if (!hook) {
552 hook = objectType->m_CopyHookData.GetPathHook(stream.In());
553 }
554 if ( hook )
555 hook->CopyObject(stream, objectType);
556 else
557 objectType->DefaultCopyData(stream);
558 }
559
560
CNamespaceInfoItem(void)561 CNamespaceInfoItem::CNamespaceInfoItem(void)
562 {
563 m_NsPrefixSet = false;
564 m_NsQualified = eNSQNotSet;
565 }
566
CNamespaceInfoItem(const CNamespaceInfoItem & other)567 CNamespaceInfoItem::CNamespaceInfoItem(const CNamespaceInfoItem& other)
568 {
569 m_NsName = other.m_NsName;
570 m_NsPrefix = other.m_NsPrefix;
571 m_NsPrefixSet = other.m_NsPrefixSet;
572 m_NsQualified = other.m_NsQualified;
573 }
574
~CNamespaceInfoItem(void)575 CNamespaceInfoItem::~CNamespaceInfoItem(void)
576 {
577 }
578
HasNamespaceName(void) const579 bool CNamespaceInfoItem::HasNamespaceName(void) const
580 {
581 return !m_NsName.empty();
582 }
583
GetNamespaceName(void) const584 const string& CNamespaceInfoItem::GetNamespaceName(void) const
585 {
586 return m_NsName;
587 }
588
SetNamespaceName(const string & ns_name)589 void CNamespaceInfoItem::SetNamespaceName(const string& ns_name)
590 {
591 m_NsName = ns_name;
592 }
593
HasNamespacePrefix(void) const594 bool CNamespaceInfoItem::HasNamespacePrefix(void) const
595 {
596 return m_NsPrefixSet;
597 }
598
GetNamespacePrefix(void) const599 const string& CNamespaceInfoItem::GetNamespacePrefix(void) const
600 {
601 return m_NsPrefix;
602 }
603
SetNamespacePrefix(const string & ns_prefix)604 void CNamespaceInfoItem::SetNamespacePrefix(const string& ns_prefix)
605 {
606 m_NsPrefix = ns_prefix;
607 m_NsPrefixSet = !m_NsPrefix.empty();
608 }
609
IsNsQualified(void)610 ENsQualifiedMode CNamespaceInfoItem::IsNsQualified(void)
611 {
612 return m_NsQualified;
613 }
614
SetNsQualified(bool qualified)615 void CNamespaceInfoItem::SetNsQualified(bool qualified)
616 {
617 m_NsQualified = qualified ? eNSQualified : eNSUnqualified;
618 }
619
620 END_NCBI_SCOPE
621