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

Go to the SVN repository for this file.

1 /* $Id: table_field.cpp 66088 2015-01-29 19:47:52Z 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: Eugene Vasilchenko
27 *
28 * File Description:
29 * CSeq_table_Info -- parsed information about Seq-table and its columns
30 *
31 */
32 
33 #include <ncbi_pch.hpp>
43 #include <objmgr/error_codes.hpp>
44 
45 #include <objmgr/feat_ci.hpp>
46 #include <objmgr/table_field.hpp>
47 
50 
51 
52 /////////////////////////////////////////////////////////////////////////////
53 // CTableFieldHandle_Base
54 /////////////////////////////////////////////////////////////////////////////
55 
56 
58  : m_FieldId(field_id)
59 {
60 }
61 
62 
64  : m_FieldId(CSeqTable_column_info::GetIdForName(field_name)),
65  m_FieldName(field_name)
66 {
67 }
68 
69 
71 {
72 }
73 
74 
75 const CSeqTable_column*
77 {
78  if ( &annot != m_CachedAnnotInfo ) {
79  m_CachedAnnotInfo = &annot;
81  if ( m_FieldId < 0 ) {
83  }
84  else {
86  }
87  if ( column ) {
88  m_CachedFieldInfo = column->Get();
89  }
90  else {
91  m_CachedFieldInfo = null;
92  }
93  }
95 }
96 
97 
98 const CSeqTable_column&
100 {
101  const CSeqTable_column* column = x_FindColumn(annot);
102  if ( !column ) {
103  if ( m_FieldId < 0 ) {
104  NCBI_THROW_FMT(CAnnotException, eOtherError,
105  "CTableFieldHandle: "
106  "column "<<m_FieldName<<" not found");
107  }
108  else {
109  NCBI_THROW_FMT(CAnnotException, eOtherError,
110  "CTableFieldHandle: "
111  "column "<<m_FieldId<<" not found");
112  }
113  }
114  return *column;
115 }
116 
117 
118 const string*
120  const string* /*dummy*/,
121  bool force) const
122 {
123  const string* ret = 0;
124  if ( const CSeqTable_column* column = x_FindColumn(feat_ci) ) {
125  ret = column->GetStringPtr(x_GetRow(feat_ci));
126  }
127  if ( !ret && force ) {
129  }
130  return ret;
131 }
132 
133 
134 const string*
136  size_t row,
137  const string* /*dummy*/,
138  bool force) const
139 {
140  const string* ret = 0;
141  if ( const CSeqTable_column* column = x_FindColumn(annot) ) {
142  ret = column->GetStringPtr(row);
143  }
144  if ( !ret && force ) {
146  }
147  return ret;
148 }
149 
150 
151 const vector<char>*
153  const vector<char>* /*dummy*/,
154  bool force) const
155 {
156  const vector<char>* ret = 0;
157  if ( const CSeqTable_column* column = x_FindColumn(feat_ci) ) {
158  ret = column->GetBytesPtr(x_GetRow(feat_ci));
159  }
160  if ( !ret && force ) {
162  }
163  return ret;
164 }
165 
166 
167 const vector<char>*
169  size_t row,
170  const vector<char>* /*dummy*/,
171  bool force) const
172 {
173  const vector<char>* ret = 0;
174  if ( const CSeqTable_column* column = x_FindColumn(annot) ) {
175  ret = column->GetBytesPtr(row);
176  }
177  if ( !ret && force ) {
179  }
180  return ret;
181 }
182 
183 
185 {
186  NCBI_THROW(CAnnotException, eOtherError,
187  "CTableFieldHandle::Get: value is not set");
188 }
189 
190 
Annotation iterators exceptions.
CFeat_CI –.
Definition: feat_ci.hpp:64
const CSeqTableColumnInfo * FindColumn(int field_id) const
CSeq_annot_Handle –.
const CSeqTableInfo & GetTableInfo(void) const
const string * GetPtr(const CFeat_CI &feat_ci, const string *dummy, bool force=false) const
CConstRef< CSeqTable_column > m_CachedFieldInfo
CTableFieldHandle_Base(CSeqTable_column_info::TField_id field_id)
Definition: table_field.cpp:57
const CSeqTable_column & x_GetColumn(const CSeq_annot_Info &annot) const
Definition: table_field.cpp:99
CConstRef< CSeq_annot_Info > m_CachedAnnotInfo
bool x_ThrowUnsetValue(void) const
const CSeqTable_column * x_FindColumn(const CSeq_annot_Info &annot) const
Definition: table_field.cpp:76
size_t x_GetRow(const CFeat_CI &feat_ci) const
static const char * column
Definition: stats.c:23
#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
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
Definition: ncbiexpt.hpp:719
TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:1672
#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
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
Definition of all error codes used in objmgr libraries (xobjmgr.lib, xobjutil.lib and others).
#define row(bind, expected)
Definition: string_bind.c:73
Modified on Thu Apr 11 15:05:27 2024 by modify_doxy.py rev. 669887