23 #ifndef COM_DAFER45_TBTK_PROPERTY_EXTRACTOR_PATTERN_VALIDATOR
24 #define COM_DAFER45_TBTK_PROPERTY_EXTRACTOR_PATTERN_VALIDATOR
31 namespace PropertyExtractor{
100 const std::vector<Subindex> &allowedSubindexFlags
118 void validate(
const std::vector<Index> &patterns)
const;
121 int numRequiredComponentIndices;
124 std::vector<Subindex> allowedSubindexFlags;
127 std::string callingFunctionName;
131 void validateNumRequiredComponentIndices(
132 const std::vector<Index> &patterns
138 void validateAllowedSubindexFlags(
139 const std::vector<Index> &patterns
144 numRequiredComponentIndices = -1;
148 int numRequiredComponentIndices
150 this->numRequiredComponentIndices = numRequiredComponentIndices;
154 const std::vector<Subindex> &allowedSubindexFlags
156 this->allowedSubindexFlags = allowedSubindexFlags;
160 const std::string &callingFunctionName
162 this->callingFunctionName = callingFunctionName;
166 const std::vector<Index> &patterns
168 if(numRequiredComponentIndices != -1)
169 validateNumRequiredComponentIndices(patterns);
170 validateAllowedSubindexFlags(patterns);
173 inline void PatternValidator::validateNumRequiredComponentIndices(
174 const std::vector<Index> &patterns
176 for(
unsigned int n = 0; n < patterns.size(); n++){
178 patterns[n].split().size()
179 == (
unsigned int)numRequiredComponentIndices,
181 "Unexpected number of pattern component Indices. The"
182 <<
" pattern was expected to have '"
183 << numRequiredComponentIndices <<
"', but the pattern"
184 <<
" '" << patterns[n].toString() <<
"' has '"
185 << patterns[n].split().size() <<
"' components.",
191 inline void PatternValidator::validateAllowedSubindexFlags(
192 const std::vector<Index> &patterns
194 for(
unsigned int n = 0; n < patterns.size(); n++){
195 std::vector<Index> components = patterns[n].split();
196 for(
unsigned int m = 0; m < components.size(); m++){
197 for(
unsigned int c = 0; c < components[m].getSize(); c++){
198 int subindex = components[m][c];
200 bool isValid =
false;
203 k < allowedSubindexFlags.size();
208 == allowedSubindexFlags[k]
218 "Invalid subindex at"
219 <<
" position '" << c
222 <<
"' of the pattern '"
223 << patterns[n].toString()