a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
SlhaSimplisticInterpreter.cpp
Go to the documentation of this file.
1/*
2 * SlhaSimplisticInterpreter.cpp
3 *
4 * Created on: Sep 13, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 */
7
8#include "SLHA.hpp"
9
10namespace LHPC
11{
13 std::string const& slhaFilename ) :
14 slhaParser( true,
15 false ),
16 stringParser()
17 {
18 slhaParser.readFile( slhaFilename );
19 }
20
22 {
23 // does nothing.
24 }
25
26
27 std::string
28 SlhaSimplisticInterpreter::operator()( std::string blockNameAndIndices )
29 {
30 std::string returnString( "" );
32 '[',
33 ' ' );
35 ']',
36 ' ' );
38 '(',
39 ' ' );
41 ')',
42 ' ' );
43 std::string indicesString( "" );
44 std::string blockName( BOL::StringParser::substringToFirst(
45 BOL::StringParser::trimFromFront( blockNameAndIndices,
47 " ",
48 &indicesString ) );
49 std::vector< int >
50 indicesVector( BOL::StringParser::stringToIntVector( indicesString ) );
52 blockPointer( slhaParser.getBlockAsStrings( blockName ) );
53 if( NULL == blockPointer )
54 {
55 return returnString;
56 }
58 blockAsStrings( (*blockPointer)[ 0 ] );
60
61 for( int whichLine( blockAsStrings.getNumberOfBodyLines() );
62 0 < whichLine;
63 --whichLine )
64 {
65 blockLine.clearEntries();
66 BOL::StringParser::parseByChar( blockAsStrings[ whichLine ].first,
67 blockLine,
69 bool indicesMatch( false );
70 if( blockLine.getSize() > (int)(indicesVector.size()) )
71 {
72 indicesMatch = true;
73 for( unsigned int whichIndex( 0 );
74 indicesVector.size() > whichIndex;
75 ++whichIndex )
76 {
77 if( indicesVector[ whichIndex ]
78 != BOL::StringParser::stringToInt( blockLine[ whichIndex ] ) )
79 {
80 indicesMatch = false;
81 break;
82 }
83 }
84 }
85 if( indicesMatch )
86 {
87 for( int whichReturnWord( indicesVector.size() );
88 blockLine.getSize() > whichReturnWord;
89 ++whichReturnWord )
90 {
91 returnString.append( blockLine[ whichReturnWord ] );
92 if( blockLine.getLastIndex() > whichReturnWord )
93 {
94 returnString.append( " " );
95 }
96 }
97 break;
98 }
99 }
100 return returnString;
101 }
102
103} /* namespace LHPC */
static std::string const whitespaceAndNewlineChars
static std::vector< int > stringToIntVector(std::string stringToInterpret)
static std::string const whitespaceChars
static void substituteCharacterWith(std::string &stringToTransform, char const charToBeReplaced, char const charToBePutIn)
static std::string trimFromFront(std::string const &stringToTrim, std::string const &charsToTrim)
static std::string substringToFirst(std::string const &stringToParse, VectorlikeArray< std::string > const &delimitersOfSubstring, std::string *const remainderString=NULL)
static int stringToInt(std::string const &stringToInterpret)
static void parseByChar(std::string const &stringToParse, VectorlikeArray< std::string > &destinationArray, std::string const &divisionCharSet=whitespaceChars)
VectorlikeArray< StoredClass > & clearEntries()
SLHA::SameNameBlockSet * getBlockAsStrings(std::string blockName)
Definition: SlhaParser.hpp:132
bool readFile(std::string const &slhaFileName)
Definition: SlhaParser.cpp:167
SlhaSimplisticInterpreter(std::string const &slhaFilename)
std::string operator()(std::string blockNameAndIndices)