Deleted Added
sdiff udiff text old ( 13414:1b5387dccec3 ) new ( 13415:dfba7ea400e2 )
full compact
1/*
2 * Copyright (c) 2015, 2018 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 271 unchanged lines hidden (view full) ---

280
281template <class T>
282void
283showParam(CheckpointOut &os, const T &value)
284{
285 os << value;
286}
287
288template <class T>
289bool
290parseParam(const std::string &s, BitUnionType<T> &value)
291{
292 auto storage = static_cast<BitUnionBaseType<T>>(value);
293 auto res = to_number(s, storage);
294 value = storage;
295 return res;
296}
297
298template <class T>
299void
300showParam(CheckpointOut &os, const BitUnionType<T> &value)
301{
302 auto storage = static_cast<BitUnionBaseType<T>>(value);
303
304 // For a BitUnion8, the storage type is an unsigned char.
305 // Since we want to serialize a number we need to cast to
306 // unsigned int
307 os << ((sizeof(storage) == 1) ?
308 static_cast<unsigned int>(storage) : storage);
309}
310
311// Treat 8-bit ints (chars) as ints on output, not as chars
312template <>
313inline void
314showParam(CheckpointOut &os, const char &value)
315{
316 os << (int)value;
317}
318

--- 53 unchanged lines hidden (view full) ---

372void
373paramOut(CheckpointOut &os, const std::string &name, const T &param)
374{
375 os << name << "=";
376 showParam(os, param);
377 os << "\n";
378}
379
380template <class T>
381void
382paramIn(CheckpointIn &cp, const std::string &name, T &param)
383{
384 const std::string &section(Serializable::currentSection());
385 std::string str;
386 if (!cp.find(section, name, str) || !parseParam(str, param)) {
387 fatal("Can't unserialize '%s:%s'\n", section, name);
388 }
389}
390
391template <class T>
392bool
393optParamIn(CheckpointIn &cp, const std::string &name,
394 T &param, bool warn = true)
395{
396 const std::string &section(Serializable::currentSection());
397 std::string str;
398 if (!cp.find(section, name, str) || !parseParam(str, param)) {
399 if (warn)
400 warn("optional parameter %s:%s not present\n", section, name);
401 return false;
402 } else {
403 return true;
404 }
405}
406
407template <class T>
408void
409arrayParamOut(CheckpointOut &os, const std::string &name,
410 const std::vector<T> &param)
411{
412 typename std::vector<T>::size_type size = param.size();
413 os << name << "=";
414 if (size > 0)

--- 201 unchanged lines hidden (view full) ---

616 fatal(err);
617 }
618
619 // assign parsed value to vector
620 param.insert(scalar_value);
621 }
622}
623
624void
625debug_serialize(const std::string &cpt_dir);
626
627void
628objParamIn(CheckpointIn &cp, const std::string &name, SimObject * &param);
629
630//
631// These macros are streamlined to use in serialize/unserialize

--- 50 unchanged lines hidden ---