11 typedef std::map<std::string, SniperJSON>::const_iterator
map_iterator;
26 bool isMap()
const {
return m_type == 1; }
33 template <
typename T> T
get()
const;
76 typedef std::string::size_type StrCursor;
83 std::vector<SniperJSON> m_jvec;
85 std::map<std::string, SniperJSON> m_jmap;
88 static const std::string SPACES;
90 static const std::string DELIMITS;
93 SniperJSON(
const std::string& jstr, StrCursor& cursor );
96 void init(
const std::string& jstr, StrCursor& cursor );
99 char getValidChar(
const std::string& jstr, StrCursor& cursor );
102 void readObjectMap(
const std::string& jstr, StrCursor& cursor );
105 void readArrayVec(
const std::string& jstr, StrCursor& cursor );
108 void readStringStr(
const std::string& jstr, StrCursor& cursor );
111 void readScalarStr(
const std::string& jstr, StrCursor& cursor );
114 template <
typename T>
inline void toCppVar( T& var )
const;
117 template <
typename T>
inline void toCppVar( std::vector<T>& var )
const;
120 template <
typename K,
typename V>
inline void toCppVar( std::map<K, V>& var )
const;
123 class Exception :
public std::exception {
125 Exception(
const std::string& msg );
126 Exception(
const std::string& jstr,
int cursor );
127 virtual ~Exception() throw();
128 const
char* what() const throw();
141template <
typename T>
inline void SniperJSON::toCppVar( T& var )
const {
144 std::stringstream ss;
148 if ( ss.eof() ) {
return; }
151 throw Exception( std::string(
"cannot set <" ) +
typeid( T ).name() +
"> with '" + m_jvar +
155template <>
inline void SniperJSON::toCppVar<bool>(
bool& var )
const {
158 if ( m_jvar ==
"true" )
163 else if ( m_jvar ==
"false" )
170 throw Exception( std::string(
"cannot set <bool> with '" ) + m_jvar +
"'" );
173template <>
inline void SniperJSON::toCppVar<std::string>( std::string& var )
const {
176 var = m_jvar.substr( 1, m_jvar.size() - 2 );
180 throw Exception( std::string(
"cannot set <std::string> with '" ) + m_jvar +
"'" );
183template <
typename T>
inline void SniperJSON::toCppVar( std::vector<T>& var )
const {
186 for (
vec_iterator it = m_jvec.begin(); it != m_jvec.end(); ++it )
187 { var.push_back( it->get<T>() ); }
191 throw Exception( std::string(
"not a valid vector" ) );
209template <
typename K,
typename V>
210inline void SniperJSON::toCppVar( std::map<K, V>& var )
const {
213 for (
map_iterator it = m_jmap.begin(); it != m_jmap.end(); ++it )
218 : it->first.substr( 1, it->first.size() - 2 ) )
220 it->second.get<V>() ) );
225 throw Exception( std::string(
"not a valid map" ) );
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
bool insert(const std::string &key, const SniperJSON &val)
std::vector< SniperJSON >::const_iterator vec_iterator
static SniperJSON loads(const std::string &jstr)
map_iterator find(const std::string &key) const
std::map< std::string, SniperJSON >::const_iterator map_iterator
map_iterator map_begin() const
bool push_back(const SniperJSON &var)
static SniperJSON load(std::istream &is)
SniperJSON & operator[](int index)
vec_iterator vec_end() const
map_iterator map_end() const
vec_iterator vec_begin() const
const SniperJSON & operator[](int index) const