a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
IndexedInterpreter.hpp
Go to the documentation of this file.
1/*
2 * IndexedInterpreter.hpp
3 *
4 * Created on: Mar 12, 2012
5 * Author: Ben O'Leary (benjamin.oleary@gmail.com)
6 * Copyright 2012 Ben O'Leary
7 *
8 * This file is part of LesHouchesParserClasses, released under the
9 * GNU General Public License. Please see the accompanying
10 * README.LHPC_CPP.txt file for a full list of files, brief documentation
11 * on how to use these classes, and further details on the license.
12 */
13
14#ifndef INDEXEDINTERPRETER_HPP_
15#define INDEXEDINTERPRETER_HPP_
16
18
19namespace LHPC
20{
21 namespace SLHA
22 {
23 namespace InterpreterClass
24 {
25 // this class extends InterpreterTemplate for blocks with an
26 // index or with indices.
27 template< class ValueClass >
28 class IndexedInterpreter : public InterpreterTemplate< ValueClass >
29 {
30 public:
32 virtual
34
35 virtual void
36 setIndexDigits( std::vector< int > const& indexDigitsVector );
37
38
39 protected:
40 std::vector< int > indexDigitsVector;
41 // this is the number of characters to print before the value,
42 // including the characters used to print the index, for each index.
43 std::vector< int > indexPrintingVector;
45 std::string indexHoldingString;
47
48 std::string const&
50 /* this puts a single space then each indexPrintingVector entry with
51 * its corresponding indexDigitsVector entry into indexPrintingString &
52 * returns it.
53 */
54 };
55
56
57
58
59
60 template< class ValueClass >
61 inline
63 InterpreterTemplate< ValueClass >(),
64 indexDigitsVector(),
65 indexPrintingVector(),
66 indexPrintingString( "" ),
67 indexHoldingString( "" ),
68 indexPadding( 0 )
69 {
70 // just an initialization list.
71 }
72
73 template< class ValueClass >
74 inline
76 {
77 // does nothing.
78 }
79
80
81 template< class ValueClass >
82 inline void
84 std::vector< int > const& indexDigitsVector )
85 {
86 this->indexDigitsVector = indexDigitsVector;
87 this->indexPrintingVector.assign( indexDigitsVector.size(),
88 0 );
89 }
90
91 template< class ValueClass >
92 inline std::string const&
94 /* this puts a single space then each indexPrintingVector entry with
95 * its corresponding indexDigitsVector entry into indexPrintingString &
96 * returns it.
97 */
98 {
99 indexPrintingString.clear();
100 for( unsigned int whichIndex( 0 );
101 this->indexDigitsVector.size() > whichIndex;
102 ++whichIndex )
103 {
104 indexHoldingString.assign(
106 indexPrintingVector[ whichIndex ] ) );
107 indexPadding = ( indexDigitsVector[ whichIndex ]
108 - indexHoldingString.size() + 1 );
109 if( 0 < indexPadding )
110 {
111 indexPrintingString.append( indexPadding,
112 ' ' );
113 }
114 else
115 {
116 indexPrintingString.append( " " );
117 }
118 indexPrintingString.append( indexHoldingString );
119 }
120 return indexPrintingString;
121 }
122
123 }
124
125 }
126
127}
128
129#endif /* INDEXEDINTERPRETER_HPP_ */
static BOL::StringParser const slhaIntHelper
virtual void setIndexDigits(std::vector< int > const &indexDigitsVector)