ISIS Logo
lvDCOM
An EPICS support module to export LabVIEW values 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 "convertToString.h"
13 
14 #ifdef _WIN32
15 #define snprintf _snprintf
16 #endif /* _WIN32 */
17 
19 template<typename T>
20 std::string convertToString(T t)
21 {
22  should_never_get_called;
23 }
24 
25 template<>
26 std::string convertToString(double t)
27 {
28  char buffer[30];
29  snprintf(buffer, sizeof(buffer), "%f", t);
30  return buffer;
31 }
32 
33 template<>
34 std::string convertToString(int t)
35 {
36  char buffer[30];
37  snprintf(buffer, sizeof(buffer), "%d", t);
38  return buffer;
39 }
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