14#ifndef SPARSEQUADRUPLYINDEXED_HPP_
15#define SPARSEQUADRUPLYINDEXED_HPP_
24 namespace InterpreterClass
28 template<
class ValueClass >
32 typedef typename std::pair< int, int >
IntPair;
53 int const secondIndex,
55 int const fourthIndex )
56 {
return (*
this)( std::make_pair( std::make_pair( firstIndex,
58 std::make_pair( thirdIndex,
62 int const secondIndex,
64 int const fourthIndex )
const
65 {
return (*
this)( std::make_pair( std::make_pair( firstIndex,
67 std::make_pair( thirdIndex,
78 int const secondIndex,
80 int const fourthIndex )
const
81 {
return (*
this)(
hasEntry( std::make_pair( std::make_pair( firstIndex,
83 std::make_pair( thirdIndex,
84 fourthIndex ) ) ) ) ; }
85 virtual std::string
const&
95 std::map< IntQuadruple, ValueClass >::const_iterator
110 template<
class ValueClass >
115 mapKey( std::pair< int, int >( 0,
117 std::pair< int, int >( 0,
124 template<
class ValueClass >
132 template<
class ValueClass >
141 if( 0 >= valueMap.count( indexQuadruple ) )
143 valueMap[ indexQuadruple ] = this->defaultUnsetValue;
145 return valueMap[ indexQuadruple ];
148 template<
class ValueClass >
149 inline ValueClass
const&
157 mapIterator valueFinder( valueMap.find( indexQuadruple ) );
158 if( valueMap.end() != valueFinder )
160 return valueFinder->second;
164 return this->defaultUnsetValue;
168 template<
class ValueClass >
174 return ( 0 < valueMap.count( indexQuadruple ) );
177 template<
class ValueClass >
178 inline std::string
const&
182 this->stringInterpretation.clear();
184 while( valueFinder != valueMap.end() )
186 this->indexPrintingVector[ 0 ] = valueFinder->first.first.first;
187 this->indexPrintingVector[ 1 ] = valueFinder->first.first.second;
188 this->indexPrintingVector[ 2 ] = valueFinder->first.second.first;
189 this->indexPrintingVector[ 3 ] = valueFinder->first.second.second;
190 this->stringInterpretation.append( this->indicesToPrintingString() );
191 this->stringInterpretation.append( this->valueToPrintingString(
192 valueFinder->second ) );
193 this->stringInterpretation.append(
"\n" );
196 return this->stringInterpretation;
199 template<
class ValueClass >
206 template<
class ValueClass >
210 for(
int whichLine( this->currentStringBlock->getNumberOfBodyLines() );
215 (*(this->currentStringBlock))[ whichLine ].first,
216 &(this->lineRemainderA),
218 if( !(this->currentWord.empty()) )
220 valueRecorder.first.first.first
223 this->lineRemainderA,
224 &(this->lineRemainderB),
226 if( !(this->currentWord.empty()) )
228 valueRecorder.first.first.second
231 this->lineRemainderB,
232 &(this->lineRemainderA),
234 if( !(this->currentWord.empty()) )
236 valueRecorder.first.second.first
239 this->lineRemainderA,
240 &(this->lineRemainderB),
242 if( !(this->currentWord.empty()) )
244 valueRecorder.first.second.second
246 valueRecorder.second = this->stringToValue(
248 this->lineRemainderB,
250 valueMap.insert( valueRecorder );
static std::string firstWordOf(std::string const &stringToParse, std::string *const remainderString=NULL, std::string const &separatorChars=whitespaceChars)
static std::string const whitespaceAndNewlineChars
static std::string trimFromFrontAndBack(std::string const &stringToTrim, std::string const &charsToTrim=whitespaceAndNewlineChars)
static int stringToInt(std::string const &stringToInterpret)
std::map< IntQuadruple, ValueClass > valueMap
virtual void clearEntries()
virtual ~SparseQuadruplyIndexed()
ValueClass & operator()(IntQuadruple const &indexQuadruple)
std::pair< IntQuadruple, ValueClass > valueRecorder
std::map< IntQuadruple, ValueClass >::const_iterator mapIterator
std::pair< int, int > IntPair
virtual std::string const & getAsString()
ValueClass const & operator()(int const firstIndex, int const secondIndex, int const thirdIndex, int const fourthIndex) const
bool hasEntry(int const firstIndex, int const secondIndex, int const thirdIndex, int const fourthIndex) const
virtual void interpretCurrentStringBlock()
ValueClass & operator()(int const firstIndex, int const secondIndex, int const thirdIndex, int const fourthIndex)
bool hasEntry(IntQuadruple const &indexQuadruple) const
std::pair< IntPair, IntPair > IntQuadruple