Wasatch.VCPP 1.0.19
Visual C++ driver for Wasatch Photonics spectrometers
Util.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <string>
11#include <vector>
12#include <set>
13
14namespace WasatchVCPP
15{
19 class Util
20 {
21 public:
22 static std::string sprintf(const char* fmt, ...);
23 static std::string toHex(const std::vector<uint8_t>& data);
24 static std::string toHex(const uint8_t* data, int len);
25 static std::string toLower(const std::string& s);
26 static std::string timestamp();
27 static void sleepMS(int ms);
28
35 template<typename T>
36 static std::string join(const T& values, const char* fmt, const char* delim = ", ")
37 {
38 std::string fmtDelim = sprintf("%%s%s", fmt);
39 std::string s;
40 for (typename T::const_iterator i = values.begin(); i != values.end(); i++)
41 if (s.size() == 0)
42 s += sprintf(fmt, *i);
43 else
44 s += sprintf(fmtDelim.c_str(), delim, *i);
45 return s;
46 }
47 };
48}
49
Internal class providing static utility functions for strings and whatnot.
Definition: Util.h:20
static std::string join(const T &values, const char *fmt, const char *delim=", ")
Joins an iterable containter to a delimited string.
Definition: Util.h:36
static std::string timestamp()
includes milliseconds on Windows
Definition: Util.cpp:54
Namespace encapsulating the internal implementation of WasatchVCPP; customers would not normally acce...
Definition: Driver.h:26