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

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___MACRO_FN_STRING_CONSTR__HPP
2 #define GUI_OBJUTILS___MACRO_FN_STRING_CONSTR__HPP
3 /* $Id: macro_fn_string_constr.hpp 46868 2021-11-17 16:29:03Z asztalos $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Andrea Asztalos
29  *
30  * File Description: Macro functions implementing string constraints
31  *
32  */
33 
34 /// @file macro_fn_string_constr.hpp
38 /** @addtogroup GUI_MACRO_SCRIPTS_UTIL
39  *
40  * @{
41  */
42 
44 BEGIN_SCOPE(macro)
45 
47 {
48 public:
53  ePunct
54  };
55 
56  enum ELogicType {
57  eOR,
58  eAND
59  };
60 
61  static const string sm_syn;
62 
64  virtual void TheFunction();
65 
66  static const char* sm_Upper;
67  static const char* sm_UpperAll;
68  static const char* sm_Lower;
69  static const char* sm_LowerAll;
70  static const char* sm_Punct;
71  static const char* sm_PunctAll;
72  static const char* sm_Start;
73  static const char* sm_End;
74  static const char* sm_Equal;
75  static const char* sm_Contain;
76  static const char* sm_InList;
77  static bool s_IsStringMatching(const string& fn_name);
78  static bool s_IsSynonymFile(const string& str);
79 
80 protected:
81  CMacroFunction_StringConstraints(EScopeEnum func_scope,
82  const string& type, EStrConstrCase testcase = eNotSet, ELogicType op_type = eOR);
83 
84  /// checks whether the arguments number and their type is good and sets the m_Modifier flag in case of a modifier
85  virtual bool x_ValidArguments() const;
86  virtual void x_ResetState() { m_Modifier = false; m_Constraint.Reset(); }
87  virtual bool x_IsNestedFunctionReturnValid() const;
88 
89  void x_SetModifierFlag();
90  /// builds a new string constraint to later match with the value of the field
91  void x_BuildStringConstraint(void);
92  void x_BuildCaseStringConstraint(void);
93  void x_BuildNoCaseStringConstraint(void);
94 
95  bool x_CheckStringConstraint(const CObjectInfo& oi);
96  bool x_CheckConstraintPrimitive(const string& field);
97  bool x_CheckConstraintContainer(const string& container, const string& subtype);
98  bool x_CheckConstraintWithinClass(const CObjectInfo& obj, const string& subtype);
99  bool x_CheckConstraintObjects(const CMQueryNodeValue::TObs& objs);
100  bool x_CheckAuthorNames(const CObjectInfo& obj);
101 
102  /// indicates to test for the case of the phrase
104  /// specifies the type of pattern matching
105  string m_Type;
106  /// flag that indicates that the field to be checked is a modifier
108  /// flag to indicate whether to use OR or AND operation for the input values
110  /// the string constraint
112 
113 private:
114  virtual CRef<objects::CWord_substitution> x_ReadSynonymsFor(const string& filename, const string& phrase) = 0;
115 };
116 
118 {
119 public:
121  const string& type, EStrConstrCase testcase = eNotSet, ELogicType op_type = eOR)
122  : CMacroFunction_StringConstraints(func_scope, type, testcase, op_type) {}
123 private:
124  virtual CRef<objects::CWord_substitution> x_ReadSynonymsFor(const string& filename, const string& phrase);
125 };
126 
128 {
129 public:
131  const string& type, EStrConstrCase testcase = eNotSet, ELogicType op_type = eOR)
132  : CMacroFunction_StringConstraints(func_scope, type, testcase, op_type) {}
133 private:
134  virtual CRef<objects::CWord_substitution> x_ReadSynonymsFor(const string& filename, const string& phrase);
135 };
136 
137 
138 END_SCOPE(macro)
140 
141 /* @} */
142 
143 #endif // GUI_OBJUTILS___MACRO_FN_STRING_CONSTR__HPP
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CObjectInfo –.
Definition: objectinfo.hpp:597
Base class for any user function that performs editing operations on ASN.1 data.
static const char * str(char *buf, int n)
Definition: stats.c:84
virtual void x_ResetState()
Reset the state of member variables that are set directly/indirectly from function arguments.
list< SResolvedField > TObs
Definition: macro_exec.hpp:92
static const string sm_syn
Classes related to STRING CONSTRAINTS.
bool m_Modifier
flag that indicates that the field to be checked is a modifier
CMacroFunction_StringSlowConstraints(EScopeEnum func_scope, const string &type, EStrConstrCase testcase=eNotSet, ELogicType op_type=eOR)
EStrConstrCase m_TestCase
indicates to test for the case of the phrase
CMacroFunction_StringFastConstraints(EScopeEnum func_scope, const string &type, EStrConstrCase testcase=eNotSet, ELogicType op_type=eOR)
CRef< objects::CString_constraint > m_Constraint
the string constraint
string m_Type
specifies the type of pattern matching
ELogicType m_Operation
flag to indicate whether to use OR or AND operation for the input values
virtual CRef< objects::CWord_substitution > x_ReadSynonymsFor(const string &filename, const string &phrase)=0
#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 NCBI_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
@ eNotSet
Definition: splign_app.cpp:550
Definition: type.c:6
Modified on Wed Jul 24 17:13:57 2024 by modify_doxy.py rev. 669887