Add a few configuration DPRINTFs.
Fix handling of chars (uint8_ts) in serialization. Minor cleanup. sim/param.cc: Add specialization of showParam for char: output as ints, not as characters. Clean up comments a bit. --HG-- extra : convert_revision : 96349382447d892679dda9f83c028eec64252dc0
This commit is contained in:
parent
3761bcf076
commit
a0f3ee7e17
1 changed files with 29 additions and 10 deletions
39
sim/param.cc
39
sim/param.cc
|
@ -85,8 +85,8 @@ BaseParam::die(const string &err) const
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//
|
//
|
||||||
// Integer types all use to_number for parsing and '<<' for
|
// The base implementations use to_number for parsing and '<<' for
|
||||||
// displaying
|
// displaying, suitable for integer types.
|
||||||
//
|
//
|
||||||
template <class T>
|
template <class T>
|
||||||
bool
|
bool
|
||||||
|
@ -103,8 +103,31 @@ showParam(ostream &os, const T &value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Floating-point types
|
// Template specializations:
|
||||||
|
// - char (8-bit integer)
|
||||||
|
// - floating-point types
|
||||||
|
// - bool
|
||||||
|
// - string
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// Treat 8-bit ints (chars) as ints on output, not as chars
|
||||||
|
template <>
|
||||||
|
void
|
||||||
|
showParam(ostream &os, const char &value)
|
||||||
|
{
|
||||||
|
os << (int)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void
|
||||||
|
showParam(ostream &os, const unsigned char &value)
|
||||||
|
{
|
||||||
|
os << (unsigned int)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Use sscanf() for FP types as to_number() only handles integers
|
||||||
template <>
|
template <>
|
||||||
bool
|
bool
|
||||||
parseParam(const string &s, float &value)
|
parseParam(const string &s, float &value)
|
||||||
|
@ -119,9 +142,7 @@ parseParam(const string &s, double &value)
|
||||||
return (sscanf(s.c_str(), "%lf", &value) == 1);
|
return (sscanf(s.c_str(), "%lf", &value) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Be flexible about what we take for bool
|
||||||
// bool
|
|
||||||
//
|
|
||||||
template <>
|
template <>
|
||||||
bool
|
bool
|
||||||
parseParam(const string &s, bool &value)
|
parseParam(const string &s, bool &value)
|
||||||
|
@ -141,7 +162,7 @@ parseParam(const string &s, bool &value)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display bools as strings
|
||||||
template <>
|
template <>
|
||||||
void
|
void
|
||||||
showParam(ostream &os, const bool &value)
|
showParam(ostream &os, const bool &value)
|
||||||
|
@ -150,9 +171,7 @@ showParam(ostream &os, const bool &value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
// String requires no processing to speak of
|
||||||
// string
|
|
||||||
//
|
|
||||||
template <>
|
template <>
|
||||||
bool
|
bool
|
||||||
parseParam(const string &s, string &value)
|
parseParam(const string &s, string &value)
|
||||||
|
|
Loading…
Reference in a new issue