SST  6.0.0
StructuralSimulationToolkit
stringize.h
1 // Copyright 2009-2016 Sandia Corporation. Under the terms
2 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2016, Sandia Corporation
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef _H_SST_CORE_STRINGIZE
13 #define _H_SST_CORE_STRINGIZE
14 
15 #include <sst_config.h>
16 
17 #include <string>
18 #include <cinttypes>
19 
20 namespace SST {
21 
22 inline std::string to_string(double val) {
23  char buffer[256];
24  sprintf(buffer, "%f", val);
25 
26  std::string buffer_str(buffer);
27  return buffer_str;
28 };
29 
30 inline std::string to_string(float val) {
31  char buffer[256];
32  sprintf(buffer, "%f", val);
33 
34  std::string buffer_str(buffer);
35  return buffer_str;
36 };
37 
38 inline std::string to_string(int32_t val) {
39  char buffer[256];
40  sprintf(buffer, "%" PRId32, val);
41 
42  std::string buffer_str(buffer);
43  return buffer_str;
44 };
45 
46 inline std::string to_string(int64_t val) {
47  char buffer[256];
48  sprintf(buffer, "%" PRId64, val);
49 
50  std::string buffer_str(buffer);
51  return buffer_str;
52 };
53 
54 inline std::string to_string(uint32_t val) {
55  char buffer[256];
56  sprintf(buffer, "%" PRIu32, val);
57 
58  std::string buffer_str(buffer);
59  return buffer_str;
60 };
61 
62 inline std::string to_string(uint64_t val) {
63  char buffer[256];
64  sprintf(buffer, "%" PRIu64, val);
65 
66  std::string buffer_str(buffer);
67  return buffer_str;
68 };
69 
70 }
71 
72 #endif
Definition: action.cc:17