//! Find entry. DictionaryIterator findEntry( const DictionaryPointer dictionary, const std::string& parameterName ) { DictionaryIterator iteratorDictionary = std::find_if( dictionary->begin( ), dictionary->end( ), DictionaryComparer( parameterName ) ); std::stringstream errorMessage; errorMessage << "Dictionary entry \"" << parameterName << "\" not found!" << std::endl; if ( iteratorDictionary == dictionary->end( ) ) { boost::throw_exception( boost::enable_error_info( std::runtime_error( errorMessage.str( ) ) ) ); } return iteratorDictionary; }
//! Overload ()-operator to compare data line with dictionary entry. bool DictionaryComparer::operator( )( const input_output::parsed_data_vector_utilities::ParsedDataLineMapPtr& dataLine ) const { // Get parameter name from data line map. std::string parameterName = input_output::parsed_data_vector_utilities::getField< std::string >( dataLine, input_output::field_types::general::parameterName ); // Store case-sensitive flag locally. bool isCaseSensitive = dictionaryEntry->isCaseSensitive; // Perform comparison check, taking state of isCaseSensitive in account. return ( !dictionaryEntry->parameterName.compare( parameterName ) || !( dictionaryEntry->synonyms.find( parameterName ) == dictionaryEntry->synonyms.end( ) ) ) || ( !isCaseSensitive * ( boost::iequals( dictionaryEntry->parameterName, parameterName ) || !( std::find_if( dictionaryEntry->synonyms.begin( ), dictionaryEntry->synonyms.end( ), DictionaryComparer( parameterName ) ) == dictionaryEntry->synonyms.end( ) ) ) ); }