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

Go to the SVN repository for this file.

1 /* $Id: Field_type.cpp 70398 2015-12-21 18:35:12Z 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: J. Chen
27  *
28  * File Description:
29  * if a feat matches to CField_type
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'macro.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 
40 // generated includes
42 
43 // generated classes
44 
46 
47 BEGIN_objects_SCOPE // namespace ncbi::objects::
48 
49 // destructor
51 {
52 }
53 
59 
86 };
87 
89 {
90  CRef <CFeature_field> feat_field(new CFeature_field);
92  for (unsigned i=0; i< ArraySize(cgp_ftype_fqual); i++) {
93  if (cgp_field == cgp_ftype_fqual[i].cdsgp) {
94  feat_field->SetType(cgp_ftype_fqual[i].feat_type);
95  f_qual->SetLegal_qual(cgp_ftype_fqual[i].legal_qual);
96  feat_field->SetField(*f_qual);
97  return feat_field;
98  }
99  }
100  return (CRef <CFeature_field> (0));
101 };
102 
103 static const char* dblink_name[] = {
104  "Trace Assembly Archive",
105  "BioSample",
106  "ProbeDB",
107  "Sequence Read Archive",
108  "BioProject",
109  "Assembly"
110 };
111 
113 {
114  string str(kEmptyStr);
115  if (user_obj.GetType().IsStr() && user_obj.GetType().GetStr() == "DBLink") {
116  CTempString field_name(dblink_name[(int)dblink_tp]);
117  ITERATE (vector <CRef <CUser_field> >, it, user_obj.GetData()) {
118  if ( (*it)->GetLabel().IsStr()
119  && ((*it)->GetLabel().GetStr() == field_name) ) {
120  if ( (*it)->GetData().IsStrs()) {
121  ITERATE (vector <CStringUTF8>, sit, (*it)->GetData().GetStrs()) {
123  if (str_cons.Empty() || str_cons.Match(str)) {
124  break;
125  }
126  else str = kEmptyStr;
127  }
128  }
129  else if ( (*it)->GetData().IsInts() ) {
130  ITERATE (vector <int>, iit, (*it)->GetData().GetInts()) {
131  str = NStr::IntToString(*iit);
132  if (str_cons.Empty() || str_cons.Match(str)) {
133  break;
134  }
135  else str = kEmptyStr;
136  }
137  }
138  if (!str.empty()) {
139  break;
140  }
141  }
142  }
143  }
144  return str;
145 };
146 
147 END_objects_SCOPE // namespace ncbi::objects::
148 
150 
151 /* Original file checksum: lines: 57, chars: 1723, CRC32: cfffbaf9 */
struct s_cgp2feattype_featqual Cgp2FeatType_FeatQual
static const char * dblink_name[]
Definition: Field_type.cpp:103
static const s_cgp2feattype_featqual cgp_ftype_fqual[]
Definition: Field_type.cpp:60
User-defined methods of the data storage class.
static string GetDBLinkFieldFromUserObject(const CUser_object &user_obj, EDBLink_field_type dblink_tp, const CString_constraint &str_cons)
Definition: Field_type.cpp:112
static CRef< CFeature_field > FeatureFieldFromCDSGeneProtField(ECDSGeneProt_field cgp_field)
Definition: Field_type.cpp:88
~CField_type(void)
Definition: Field_type.cpp:50
CRef –.
Definition: ncbiobj.hpp:618
bool Match(const CMatchString &str) const
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
static const char * str(char *buf, int n)
Definition: stats.c:84
constexpr size_t ArraySize(const Element(&)[Size])
Definition: ncbimisc.hpp:1532
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
static string AsSingleByteString(const CTempString &src, EEncoding encoding, const char *substitute_on_error=0, EValidate validate=eNoValidate)
Convert UTF8 string into a single-byte character representation.
Definition: ncbistr.cpp:6983
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
@ eEncoding_Ascii
Definition: ncbistr.hpp:202
bool IsStr(void) const
Check if variant Str is selected.
Definition: Object_id_.hpp:291
const TStr & GetStr(void) const
Get the variant data.
Definition: Object_id_.hpp:297
const TData & GetData(void) const
Get the Data member data.
const TType & GetType(void) const
Get the Type member data.
TLegal_qual & SetLegal_qual(void)
Select the variant.
EMacro_feature_type
feature values
ECDSGeneProt_field
Access to ECDSGeneProt_field's attributes (values, names) as defined in spec.
EFeat_qual_legal
Access to EFeat_qual_legal's attributes (values, names) as defined in spec.
EDBLink_field_type
dblink fields
@ eMacro_feature_type_mat_peptide_aa
@ eMacro_feature_type_gene
@ eMacro_feature_type_mRNA
@ eMacro_feature_type_prot
@ eMacro_feature_type_cds
@ eCDSGeneProt_field_gene_allele
@ eCDSGeneProt_field_gene_description
@ eCDSGeneProt_field_prot_description
@ eCDSGeneProt_field_mrna_product
@ eCDSGeneProt_field_mat_peptide_description
@ eCDSGeneProt_field_gene_synonym
@ eCDSGeneProt_field_cds_inference
@ eCDSGeneProt_field_gene_old_locus_tag
@ eCDSGeneProt_field_mat_peptide_comment
@ eCDSGeneProt_field_mat_peptide_ec_number
@ eCDSGeneProt_field_mat_peptide_activity
@ eCDSGeneProt_field_prot_activity
@ eCDSGeneProt_field_prot_ec_number
@ eCDSGeneProt_field_prot_name
@ eCDSGeneProt_field_gene_maploc
@ eCDSGeneProt_field_prot_comment
@ eCDSGeneProt_field_codon_start
@ eCDSGeneProt_field_mat_peptide_name
@ eCDSGeneProt_field_gene_inference
@ eCDSGeneProt_field_gene_locus
@ eCDSGeneProt_field_mrna_comment
@ eCDSGeneProt_field_gene_locus_tag
@ eCDSGeneProt_field_gene_comment
@ eCDSGeneProt_field_cds_comment
@ eFeat_qual_legal_locus_tag
@ eFeat_qual_legal_inference
@ eFeat_qual_legal_codon_start
@ eFeat_qual_legal_ec_number
@ eFeat_qual_legal_synonym
@ eFeat_qual_legal_activity
@ eFeat_qual_legal_note
@ eFeat_qual_legal_product
@ eFeat_qual_legal_gene_description
@ eFeat_qual_legal_map
@ eFeat_qual_legal_gene
@ eFeat_qual_legal_allele
@ eFeat_qual_legal_old_locus_tag
@ eFeat_qual_legal_description
int i
EFeat_qual_legal legal_qual
Definition: Field_type.cpp:57
EMacro_feature_type feat_type
Definition: Field_type.cpp:56
ECDSGeneProt_field cdsgp
Definition: Field_type.cpp:55
Modified on Sat Apr 20 12:22:03 2024 by modify_doxy.py rev. 669887