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

Go to the SVN repository for this file.

1 /* $Id: struc_table_column.cpp 68295 2015-07-27 13:54:26Z bollin $
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: Colleen Bollin
27  *
28  * File Description:
29  * Implementation of utility classes for handling source qualifiers by name
30  *
31  */
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34 #include <corelib/ncbistr.hpp>
35 
36 #include <serial/enumvalues.hpp>
37 #include <serial/serialimpl.hpp>
38 
42 #include <objmgr/scope.hpp>
43 #include <objmgr/util/sequence.hpp>
44 #include <objmgr/bioseq_ci.hpp>
45 #include <objmgr/seqdesc_ci.hpp>
47 
48 #include <vector>
49 #include <algorithm>
50 #include <list>
51 
53 
56 
57 
58 void CGenericStructuredCommentColumn::AddToComment(CUser_object & user_object, const string & newValue )
59 {
60  bool found = false;
61  NON_CONST_ITERATE (CUser_object::TData, it, user_object.SetData()) {
62  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr() && NStr::EqualNocase(m_FieldName, (*it)->GetLabel().GetStr())) {
63  (*it)->SetData().SetStr(newValue);
64  found = true;
65  }
66  }
67  if (!found) {
68  CRef<CUser_field> new_field(new CUser_field());
69  new_field->SetLabel().SetStr(m_FieldName);
70  new_field->SetData().SetStr(newValue);
71  user_object.SetData().push_back(new_field);
72  }
73 }
74 
76 {
77  if (!user_object.IsSetData()) {
78  return;
79  }
80  CUser_object::TData::iterator it = user_object.SetData().begin();
81  while (it != user_object.SetData().end()) {
82  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr() && NStr::EqualNocase(m_FieldName, (*it)->GetLabel().GetStr())) {
83  it = user_object.SetData().erase(it);
84  } else {
85  ++it;
86  }
87  }
88 }
89 
90 
92 {
93  string val = "";
94  ITERATE (CUser_object::TData, it, user_object.GetData()) {
95  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr() && NStr::EqualNocase(m_FieldName, (*it)->GetLabel().GetStr())) {
96  if ((*it)->GetData().IsStr()) {
97  val = (*it)->GetData().GetStr();
98  break;
99  }
100  }
101  }
102 
103  return val;
104 }
105 
106 
109 {
110  // do not create column handler for blank title
111  if( NStr::IsBlank(sTitle) ) {
113  }
114 
116 
117 }
118 
119 
121 {
123 
124  ITERATE (CUser_object::TData, it, src.GetData()) {
125  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()) {
126  fields.push_back(CStructuredCommentTableColumnBaseFactory::Create((*it)->GetLabel().GetStr()));
127  }
128  }
129 
130  return fields;
131 }
132 
133 
134 
135 
virtual void ClearInComment(CUser_object &user_object)
virtual string GetFromComment(const CUser_object &user_object) const
static CRef< CStructuredCommentTableColumnBase > Create(string sTitle)
Include a standard set of the NCBI C++ Toolkit most basic headers.
The NCBI C++ standard methods for dealing with std::string.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#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
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
bool IsSetData(void) const
the object itself Check if a value has been assigned to Data data member.
TData & SetData(void)
Assign a value to Data data member.
void SetLabel(TLabel &value)
Assign a value to Label data member.
const TData & GetData(void) const
Get the Data member data.
void SetData(TData &value)
Assign a value to Data data member.
vector< CRef< CUser_field > > TData
The Object manager core.
TStructuredCommentTableColumnList GetStructuredCommentFields(const CUser_object &src)
vector< CRef< CStructuredCommentTableColumnBase > > TStructuredCommentTableColumnList
#define const
Definition: zconf.h:232
Modified on Wed Jun 19 16:59:30 2024 by modify_doxy.py rev. 669887