File indexing completed on 2025-01-18 10:15:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_MATCH_HPP)
0023 #define XERCESC_INCLUDE_GUARD_MATCH_HPP
0024
0025
0026
0027
0028 #include <xercesc/util/PlatformUtils.hpp>
0029 #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
0030 #include <xercesc/util/RuntimeException.hpp>
0031
0032 XERCES_CPP_NAMESPACE_BEGIN
0033
0034
0035
0036
0037 class XMLUTIL_EXPORT Match : public XMemory
0038 {
0039 public:
0040
0041
0042
0043
0044 Match(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0045
0046
0047
0048
0049 Match(const Match& toCopy);
0050 Match& operator=(const Match& toAssign);
0051
0052 virtual ~Match();
0053
0054
0055
0056
0057 int getNoGroups() const;
0058 int getStartPos(int index) const;
0059 int getEndPos(int index) const;
0060
0061
0062
0063
0064 void setNoGroups(const int n);
0065 void setStartPos(const int index, const int value);
0066 void setEndPos(const int index, const int value);
0067
0068 private:
0069
0070
0071
0072 void initialize(const Match& toCopy);
0073 void cleanUp();
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092 int fNoGroups;
0093 int fPositionsSize;
0094 int* fStartPositions;
0095 int* fEndPositions;
0096 MemoryManager* fMemoryManager;
0097 };
0098
0099
0100
0101
0102
0103
0104
0105
0106 inline int Match::getNoGroups() const {
0107
0108 if (fNoGroups < 0)
0109 ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager);
0110
0111 return fNoGroups;
0112 }
0113
0114 inline int Match::getStartPos(int index) const {
0115
0116 if (!fStartPositions)
0117 ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager);
0118
0119 if (index < 0 || fNoGroups <= index)
0120 ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager);
0121
0122 return fStartPositions[index];
0123 }
0124
0125 inline int Match::getEndPos(int index) const {
0126
0127 if (!fEndPositions)
0128 ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager);
0129
0130 if (index < 0 || fNoGroups <= index)
0131 ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager);
0132
0133 return fEndPositions[index];
0134 }
0135
0136
0137
0138
0139 inline void Match::setStartPos(const int index, const int value) {
0140
0141 if (!fStartPositions)
0142 ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager);
0143
0144 if (index < 0 || fNoGroups <= index)
0145 ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager);
0146
0147 fStartPositions[index] = value;
0148 }
0149
0150 inline void Match::setEndPos(const int index, const int value) {
0151
0152 if (!fEndPositions)
0153 ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_Result_Not_Set, fMemoryManager);
0154
0155 if (index < 0 || fNoGroups <= index)
0156 ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Array_BadIndex, fMemoryManager);
0157
0158 fEndPositions[index] = value;
0159 }
0160
0161 XERCES_CPP_NAMESPACE_END
0162
0163 #endif