NCBI C++ ToolKit
annot_name.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef ANNOT_NAME__HPP
2 #define ANNOT_NAME__HPP
3 
4 /* $Id: annot_name.hpp 33815 2007-05-04 17:18:18Z kazimird $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Aleksey Grichenko, Michael Kimelman, Eugene Vasilchenko
30 *
31 * File Description:
32 * Annotations selector structure.
33 *
34 */
35 
36 
37 #include <corelib/ncbistd.hpp>
38 
41 
43 {
44 public:
45  CAnnotName(void)
46  : m_Named(false)
47  {
48  }
49  CAnnotName(const string& name)
50  : m_Named(true), m_Name(name)
51  {
52  }
53  CAnnotName(const char* name)
54  : m_Named(true), m_Name(name)
55  {
56  }
57 
58  bool IsNamed(void) const
59  {
60  return m_Named;
61  }
62  const string& GetName(void) const
63  {
64  _ASSERT(m_Named);
65  return m_Name;
66  }
67 
68  void SetUnnamed(void)
69  {
70  m_Named = false;
71  m_Name.erase();
72  }
73  void SetNamed(const string& name)
74  {
75  m_Name = name;
76  m_Named = true;
77  }
78 
79  bool operator<(const CAnnotName& name) const
80  {
81  return name.m_Named && (!m_Named || name.m_Name > m_Name);
82  }
83  bool operator==(const CAnnotName& name) const
84  {
85  return name.m_Named == m_Named && name.m_Name == m_Name;
86  }
87  bool operator!=(const CAnnotName& name) const
88  {
89  return name.m_Named != m_Named || name.m_Name != m_Name;
90  }
91 
92 private:
93  bool m_Named;
94  string m_Name;
95 };
96 
97 
100 
101 #endif // ANNOT_NAME__HPP
CAnnotName(const string &name)
Definition: annot_name.hpp:49
bool operator!=(const CAnnotName &name) const
Definition: annot_name.hpp:87
bool operator==(const CAnnotName &name) const
Definition: annot_name.hpp:83
string m_Name
Definition: annot_name.hpp:94
CAnnotName(const char *name)
Definition: annot_name.hpp:53
void SetNamed(const string &name)
Definition: annot_name.hpp:73
CAnnotName(void)
Definition: annot_name.hpp:45
bool m_Named
Definition: annot_name.hpp:93
const string & GetName(void) const
Definition: annot_name.hpp:62
bool IsNamed(void) const
Definition: annot_name.hpp:58
bool operator<(const CAnnotName &name) const
Definition: annot_name.hpp:79
void SetUnnamed(void)
Definition: annot_name.hpp:68
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
#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
#define _ASSERT
Modified on Wed Sep 04 15:02:27 2024 by modify_doxy.py rev. 669887