-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.h
More file actions
45 lines (36 loc) · 969 Bytes
/
string.h
File metadata and controls
45 lines (36 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2015 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <cstring>
#include <string>
#include <sstream>
#include "common.h"
#include "stream.h"
namespace prt {
template <class T>
inline std::string toString(const T& a)
{
std::stringstream sm;
sm << a;
return sm.str();
}
template <class T>
inline std::string toString(const T& a, int precision, int base = 0)
{
std::stringstream sm;
sm << std::setbase(base) << std::fixed << std::setprecision(precision) << a;
return sm.str();
}
template <class T>
inline T fromString(const std::string& str, int base = 0)
{
std::stringstream sm(str);
T a;
sm >> std::setbase(base) >> a;
return a;
}
double parseTime(const std::string& str);
Stream& operator <<(Stream& osm, const char* str);
Stream& operator <<(Stream& osm, const std::string& str);
Stream& operator >>(Stream& ism, std::string& str);
} // namespace prt