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

Go to the SVN repository for this file.

1 #ifndef REGEXP__LOC__HPP
2 #define REGEXP__LOC__HPP
3 
4 /* $Id: regexp_loc.hpp 91958 2020-12-17 12:53:44Z grichenk $
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  * Authors: Clifford Clausen
30  *
31  */
32 
33 /// @file regexp_loc.hpp
34 /// header file for creating CSeq_locs from CRegexps.
35 ///
36 /// Class definition file for CRegexp_loc which is used to convert a PCRE
37 /// match to a char* sequence into a CSeq_loc.
38 
39 
40 #include <corelib/ncbistd.hpp>
41 #include <util/xregexp/regexp.hpp>
45 
46 #include <memory>
47 
50 
51 
52 /// Class used to convert a PCRE match to a char* sequence into a CSeq_loc.
53 
55 {
56 public:
57  /// Constructor for CRegexp_loc
58 
59  /// Compiles the Perl Compatible Regular Expression (PCRE) pat, and sets
60  /// compiled pattern options. See CRegexp.hpp for more information.
61  CRegexp_loc(const string &pat, // Perl regular expression
62  CRegexp::TCompile flags = 0); // Compile options
63  virtual ~CRegexp_loc();
64 
65  /// Sets PCRE pattern
66 
67  /// Sets and compiles Perl Compatible Regular Expression (PCRE) pat, and
68  /// sets compiled pattern options. See CRegexp.hpp for more information.
69  void Set(const string &pat, // Perl regular expression
70  CRegexp::TCompile flags = 0); // Compile options
71 
72  ///Gets a CSeq_loc for PCRE match to char* sequence
73 
74  /// Gets a CSeq_loc (loc) of match between currently set regular
75  /// expression and seq. Returned loc is of type CPacked_seqint. The first
76  /// CSeq_interval in the CPacked_seqint is the overall match. Subsequent
77  /// CSeq_intervals are matches to sub-patterns. Begins search of seq at 0
78  /// based offset. Returns 0 based position of first character in seq of
79  /// match. If no match found, returns kInvalidSeqPos and loc is set to
80  /// an empty packed-int type CSeq_loc. See CRegexp.hpp for information
81  /// about flags.
82  TSeqPos GetLoc (const char *seq, // Sequence to search
83  CSeq_loc *loc, // Pattern location(s)
84  TSeqPos offset = 0, // Starting offset in sequence
85  CRegexp::TMatch flags = 0); // Match options
86 
87 private:
88  // Disable copy constructor and assignment operator
90  void operator= (const CRegexp_loc &);
91 
92  /// PCRE used to match against char* sequence passed as argument to GetLoc
93  unique_ptr<CRegexp> m_regexp;
94 };
95 
96 
98 
99 #endif /*REGEXP__LOC__HPP*/
Class used to convert a PCRE match to a char* sequence into a CSeq_loc.
Definition: regexp_loc.hpp:55
CRegexp_loc(const CRegexp_loc &)
unique_ptr< CRegexp > m_regexp
PCRE used to match against char* sequence passed as argument to GetLoc.
Definition: regexp_loc.hpp:93
Include a standard set of the NCBI C++ Toolkit most basic headers.
static uch flags
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
unsigned int TMatch
Match options.
Definition: regexp.hpp:77
unsigned int TCompile
Type definitions used for code clarity.
Definition: regexp.hpp:76
#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 NCBI_XALGOSEQ_EXPORT
Definition: ncbi_export.h:1017
USING_SCOPE(objects)
int GetLoc(const string &acc, const string &pat, CSeq_loc &loc, CScope &scope)
int offset
Definition: replacements.h:160
C++ wrappers for the Perl-compatible regular expression (PCRE) library.
Modified on Sun Feb 25 03:07:29 2024 by modify_doxy.py rev. 669887