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

Go to the SVN repository for this file.

1 /* $Id: TMgr_ClientInfo.cpp 84433 2018-11-08 15:56:37Z evgeniev $
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: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'trackmgr.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 
40 // generated includes
42 
43 #include <vector>
44 
45 #include <vector>
46 
47 // generated classes
48 
50 
51 BEGIN_objects_SCOPE // namespace ncbi::objects::
52 
53 // destructor
55 {
56 }
57 
59 {
60  // parse the context, if necessary
61  typedef vector<string> TTokens;
62 
63  static const string major_delim("::");
64  static const string minor_delim(":");
65 
67 
68  TTokens major_tokens;
69  NStr::Split(value, major_delim, major_tokens, NStr::fSplit_ByPattern);
70  bool is_context = true;
71 
72  ITERATE (TTokens, it, major_tokens) {
73  if (is_context) {
74  context = *it;
76  is_context = false;
77  }
78  else {
79  string key, val;
80  if (NStr::SplitInTwo(*it, minor_delim, key, val)) {
82  attr->SetKey(key);
83  attr->SetValue(val);
84  SetContext_attrs().push_back(attr);
85  }
86  }
87  }
88 }
89 
90 void CTMgr_ClientInfo::SetContextAttr(const string &key, const string &value)
91 {
93  attr->SetKey(key);
94  attr->SetValue(value);
95  SetContext_attrs().push_back(attr);
96 }
97 
98 const string& CTMgr_ClientInfo::GetContextAttr(const string &key) const
99 {
100  if (!IsSetContext_attrs())
101  return kEmptyStr;
102 
103  for (auto attr : GetContext_attrs()) {
104  if (!NStr::Equal(attr->GetKey(), key))
105  continue;
106 
107  return attr->GetValue();
108  }
109  return kEmptyStr;
110 }
111 
112 END_objects_SCOPE // namespace ncbi::objects::
113 
115 
116 /* Original file checksum: lines: 57, chars: 1744, CRC32: 67e32918 */
User-defined methods of the data storage class.
CRef –.
Definition: ncbiobj.hpp:618
CTMgr_AttrSpec –.
void SetContextAttr(const string &key, const string &value)
virtual TContext & SetContext(void)
const string & GetContextAttr(const string &key) const
#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 list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3452
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3545
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5378
@ fSplit_ByPattern
Require full delimiter strings.
Definition: ncbistr.hpp:2504
const TContext_attrs & GetContext_attrs(void) const
Get the Context_attrs member data.
TContext_attrs & SetContext_attrs(void)
Assign a value to Context_attrs data member.
bool IsSetContext_attrs(void) const
permission keys etc Check if a value has been assigned to Context_attrs data member.
TContext & SetContext(void)
Assign a value to Context data member.
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static CS_CONTEXT * context
Definition: will_convert.c:21
list< STokenInfo > TTokens
Definition: xgbparint.cpp:88
Modified on Fri Sep 20 14:57:32 2024 by modify_doxy.py rev. 669887