NCBI C++ Toolkit Cross Reference

  C++/src/objects/general/User_field_.cpp


/* $Id$ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * File Description: * This code was generated by application DATATOOL * using the following specifications: * 'general.asn'. * * ATTENTION: * Don't edit or commit this file into CVS as this file will * be overridden (by DATATOOL) without warning! * =========================================================================== */ // standard includes #include <ncbi_pch.hpp> #include <serial/serialimpl.hpp> // generated includes #include <objects/general/User_field.hpp> #include <objects/general/Object_id.hpp> #include <objects/general/User_object.hpp> BEGIN_NCBI_SCOPE BEGIN_objects_SCOPE // namespace ncbi::objects:: // generated classes void CUser_field_Base::C_Data::Reset(void) { if ( m_choice != e_not_set ) ResetSelection(); } void CUser_field_Base::C_Data::ResetSelection(void) { switch ( m_choice ) { case e_Os: m_Os.Destruct(); break; case e_Strs: m_Strs.Destruct(); break; case e_Ints: m_Ints.Destruct(); break; case e_Reals: m_Reals.Destruct(); break; case e_Oss: { for ( std::vector< std::vector< char >* >::iterator listIter1 = (*m_Oss).begin(); listIter1 != (*m_Oss).end(); ++listIter1 ) { delete (*listIter1); } } m_Oss.Destruct(); break; case e_Fields: m_Fields.Destruct(); break; case e_Objects: m_Objects.Destruct(); break; case e_Str: m_string_utf8.Destruct(); break; case e_Object: m_object->RemoveReference(); break; default: break; } m_choice = e_not_set; } void CUser_field_Base::C_Data::DoSelect(E_Choice index, NCBI_NS_NCBI::CObjectMemoryPool* pool) { switch ( index ) { case e_Int: m_Int = 0; break; case e_Real: m_Real = 0; break; case e_Bool: m_Bool = 0; break; case e_Os: m_Os.Construct(); break; case e_Object: (m_object = new(pool) ncbi::objects::CUser_object())->AddReference(); break; case e_Strs: m_Strs.Construct(); break; case e_Ints: m_Ints.Construct(); break; case e_Reals: m_Reals.Construct(); break; case e_Oss: m_Oss.Construct(); break; case e_Fields: m_Fields.Construct(); break; case e_Objects: m_Objects.Construct(); break; case e_Str: m_string_utf8.Construct(); break; default: break; } m_choice = index; } const char* const CUser_field_Base::C_Data::sm_SelectionNames[] = { "not set", "str", "int", "real", "bool", "os", "object", "strs", "ints", "reals", "oss", "fields", "objects" }; NCBI_NS_STD::string CUser_field_Base::C_Data::SelectionName(E_Choice index) { return NCBI_NS_NCBI::CInvalidChoiceSelection::GetName(index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0])); } void CUser_field_Base::C_Data::ThrowInvalidSelection(E_Choice index) const { throw NCBI_NS_NCBI::CInvalidChoiceSelection(DIAG_COMPILE_INFO, this, m_choice, index, sm_SelectionNames, sizeof(sm_SelectionNames)/sizeof(sm_SelectionNames[0])); } void CUser_field_Base::C_Data::SetStr(const CUser_field_Base::C_Data::TStr& value) { Select(e_Str, NCBI_NS_NCBI::eDoNotResetVariant); *m_string_utf8 = value; } const CUser_field_Base::C_Data::TObject& CUser_field_Base::C_Data::GetObject(void) const { CheckSelected(e_Object); return *static_cast<const TObject*>(m_object); } CUser_field_Base::C_Data::TObject& CUser_field_Base::C_Data::SetObject(void) { Select(e_Object, NCBI_NS_NCBI::eDoNotResetVariant); return *static_cast<TObject*>(m_object); } void CUser_field_Base::C_Data::SetObject(CUser_field_Base::C_Data::TObject& value) { TObject* ptr = &value; if ( m_choice != e_Object || m_object != ptr ) { ResetSelection(); (m_object = ptr)->AddReference(); m_choice = e_Object; } } // helper methods // type info BEGIN_NAMED_CHOICE_INFO("", CUser_field_Base::C_Data) { SET_INTERNAL_NAME("User-field", "data"); SET_CHOICE_MODULE("NCBI-General"); ADD_NAMED_BUF_CHOICE_VARIANT("str", m_string_utf8, CStringUTF8, ()); ADD_NAMED_STD_CHOICE_VARIANT("int", m_Int); ADD_NAMED_STD_CHOICE_VARIANT("real", m_Real); ADD_NAMED_STD_CHOICE_VARIANT("bool", m_Bool); ADD_NAMED_BUF_CHOICE_VARIANT("os", m_Os, STL_CHAR_vector, (char)); ADD_NAMED_REF_CHOICE_VARIANT("object", m_object, CUser_object); ADD_NAMED_BUF_CHOICE_VARIANT("strs", m_Strs, STL_vector, (CStringUTF8, ())); ADD_NAMED_BUF_CHOICE_VARIANT("ints", m_Ints, STL_vector, (STD, (int))); ADD_NAMED_BUF_CHOICE_VARIANT("reals", m_Reals, STL_vector, (STD, (double))); ADD_NAMED_BUF_CHOICE_VARIANT("oss", m_Oss, STL_vector, (POINTER, (STL_CHAR_vector, (char)))); ADD_NAMED_BUF_CHOICE_VARIANT("fields", m_Fields, STL_vector, (STL_CRef, (CLASS, (CUser_field)))); ADD_NAMED_BUF_CHOICE_VARIANT("objects", m_Objects, STL_vector, (STL_CRef, (CLASS, (CUser_object)))); info->CodeVersion(21700); info->DataSpec(ncbi::EDataSpec::eASN); } END_CHOICE_INFO // constructor CUser_field_Base::C_Data::C_Data(void) : m_choice(e_not_set) { } // destructor CUser_field_Base::C_Data::~C_Data(void) { Reset(); } void CUser_field_Base::ResetLabel(void) { if ( !m_Label ) { m_Label.Reset(new TLabel()); return; } (*m_Label).Reset(); } void CUser_field_Base::SetLabel(CUser_field_Base::TLabel& value) { m_Label.Reset(&value); } void CUser_field_Base::ResetData(void) { if ( !m_Data ) { m_Data.Reset(new TData()); return; } (*m_Data).Reset(); } void CUser_field_Base::SetData(CUser_field_Base::TData& value) { m_Data.Reset(&value); } void CUser_field_Base::Reset(void) { ResetLabel(); ResetNum(); ResetData(); } BEGIN_NAMED_BASE_CLASS_INFO("User-field", CUser_field) { SET_CLASS_MODULE("NCBI-General"); ADD_NAMED_REF_MEMBER("label", m_Label, CObject_id); ADD_NAMED_STD_MEMBER("num", m_Num)->SetSetFlag(MEMBER_PTR(m_set_State[0]))->SetOptional(); ADD_NAMED_REF_MEMBER("data", m_Data, C_Data); info->RandomOrder(); info->CodeVersion(21700); info->DataSpec(ncbi::EDataSpec::eASN); } END_CLASS_INFO // constructor CUser_field_Base::CUser_field_Base(void) : m_Num(0) { memset(m_set_State,0,sizeof(m_set_State)); if ( !IsAllocatedInPool() ) { ResetLabel(); ResetData(); } } // destructor CUser_field_Base::~CUser_field_Base(void) { } END_objects_SCOPE // namespace ncbi::objects:: END_NCBI_SCOPE

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.