serialize.cc (9983:2cce74fe359e) | serialize.cc (10386:c81407818741) |
---|---|
1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * Copyright (c) 2013 Advanced Micro Devices, Inc. 4 * Copyright (c) 2013 Mark D. Hill and David A. Wood 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are --- 97 unchanged lines hidden (view full) --- 106template <> 107void 108showParam(ostream &os, const unsigned char &value) 109{ 110 os << (unsigned int)value; 111} 112 113 | 1/* 2 * Copyright (c) 2002-2005 The Regents of The University of Michigan 3 * Copyright (c) 2013 Advanced Micro Devices, Inc. 4 * Copyright (c) 2013 Mark D. Hill and David A. Wood 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are --- 97 unchanged lines hidden (view full) --- 106template <> 107void 108showParam(ostream &os, const unsigned char &value) 109{ 110 os << (unsigned int)value; 111} 112 113 |
114// Use sscanf() for FP types as to_number() only handles integers | |
115template <> 116bool 117parseParam(const string &s, float &value) 118{ | 114template <> 115bool 116parseParam(const string &s, float &value) 117{ |
119 return (sscanf(s.c_str(), "%f", &value) == 1); | 118 return to_number(s, value); |
120} 121 122template <> 123bool 124parseParam(const string &s, double &value) 125{ | 119} 120 121template <> 122bool 123parseParam(const string &s, double &value) 124{ |
126 return (sscanf(s.c_str(), "%lf", &value) == 1); | 125 return to_number(s, value); |
127} 128 129template <> 130bool 131parseParam(const string &s, bool &value) 132{ | 126} 127 128template <> 129bool 130parseParam(const string &s, bool &value) 131{ |
133 const string &ls = to_lower(s); 134 135 if (ls == "true") { 136 value = true; 137 return true; 138 } 139 140 if (ls == "false") { 141 value = false; 142 return true; 143 } 144 145 return false; | 132 return to_bool(s, value); |
146} 147 148// Display bools as strings 149template <> 150void 151showParam(ostream &os, const bool &value) 152{ 153 os << (value ? "true" : "false"); --- 502 unchanged lines hidden --- | 133} 134 135// Display bools as strings 136template <> 137void 138showParam(ostream &os, const bool &value) 139{ 140 os << (value ? "true" : "false"); --- 502 unchanged lines hidden --- |