1 /*  $Id: sage_manip.cpp 369200 2012-07-17 15:33:42Z ivanov $
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:  Mike DiCuccio
27  *
28  * File Description:
29  *    CSageManip -- manipulator for SAGE data; encodes/decodes from
30  *                  a CUser_object
31  */
32 
33 #include <ncbi_pch.hpp>
34 #include <objtools/manip/sage_manip.hpp>
35 #include <objects/general/User_field.hpp>
36 
37 
38 BEGIN_NCBI_SCOPE
39 BEGIN_SCOPE(objects)
40 
41 
42 static const char* sc_tag    = "tag";
43 static const char* sc_count  = "count";
44 static const char* sc_method = "method";
45 
46 
47 
CConstSageData(const CUser_object & obj)48 CConstSageData::CConstSageData(const CUser_object& obj)
49     : m_Object(const_cast<CUser_object*>(&obj))
50 {
51 }
52 
53 
~CConstSageData()54 CConstSageData::~CConstSageData()
55 {
56 }
57 
58 
GetTag(void) const59 const string& CConstSageData::GetTag(void) const
60 {
61     return m_Object->GetField(sc_tag).GetData().GetStr();
62 }
63 
64 
GetCount(void) const65 int CConstSageData::GetCount(void) const
66 {
67     return m_Object->GetField(sc_count).GetData().GetInt();
68 }
69 
70 
GetField(const string & field,const string & delim)71 const CUser_field& CConstSageData::GetField(const string& field,
72                                             const string& delim)
73 {
74     return m_Object->GetField(field, delim);
75 }
76 
77 
78 
CSageData(CUser_object & obj)79 CSageData::CSageData(CUser_object& obj)
80     : CConstSageData(obj)
81 {
82 }
83 
84 
SetTag(void)85 string& CSageData::SetTag(void)
86 {
87     return m_Object->SetField(sc_tag).SetData().SetStr();
88 }
89 
90 
SetTag(const string & str)91 void CSageData::SetTag(const string& str)
92 {
93     m_Object->SetField(sc_tag).SetData().SetStr(str);
94 }
95 
96 
SetMethod(void)97 string& CSageData::SetMethod(void)
98 {
99     return m_Object->SetField(sc_method).SetData().SetStr();
100 }
101 
102 
SetMethod(const string & str)103 void CSageData::SetMethod(const string& str)
104 {
105     m_Object->SetField(sc_method).SetData().SetStr(str);
106 }
107 
108 
SetCount(int count)109 void CSageData::SetCount(int count)
110 {
111     m_Object->SetField(sc_count).SetData().SetInt(count);
112 }
113 
114 
SetField(const string & field)115 CUser_field& CSageData::SetField(const string& field)
116 {
117     return m_Object->SetField(field);
118 }
119 
120 
SetField(const string & field,const string & value)121 CUser_field& CSageData::SetField(const string& field, const string& value)
122 {
123     CUser_field& f = m_Object->SetField(field);
124     f.SetData().SetStr(value);
125     return f;
126 }
127 
128 
129 END_SCOPE(objects)
130 END_NCBI_SCOPE
131