ISIS Logo
NetShrVar
An EPICS support module to export National Instruments Network Shared Variables as process variables
convertToString.cpp
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2013 Science and Technology Facilities Council (STFC), GB.
3 * All rights reverved.
4 * This file is distributed subject to a Software License Agreement found
5 * in the file LICENSE.txt that is included with this distribution.
6 \*************************************************************************/
7 
10 
11 #include <string>
12 #include <cstdio>
13 #include "convertToString.h"
14 
15 #ifdef _WIN32
16 #define snprintf _snprintf
17 #endif /* _WIN32 */
18 
20 template<typename T>
21 std::string convertToString(T t)
22 {
23  should_never_get_called(t);
24  return "";
25 }
26 
27 template<>
28 std::string convertToString(double t)
29 {
30  char buffer[30];
31  snprintf(buffer, sizeof(buffer), "%f", t);
32  return buffer;
33 }
34 
35 template<>
36 std::string convertToString(int t)
37 {
38  char buffer[30];
39  snprintf(buffer, sizeof(buffer), "%d", t);
40  return buffer;
41 }
std::string convertToString(T t)
Convert a numeric type to a string.
Header for templated number to string conversion functions.
Copyright © 2013 Science and Technology Facilities Council | Generated by   doxygen 1.8.5