-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.hpp
54 lines (44 loc) · 913 Bytes
/
form.hpp
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
46
47
48
49
50
51
52
53
54
/*\
*
* File: form.hpp
* Language: C++
*
* Author: culb ( nightfrog )
*
* Methods to form the values returned from the CPUID instruction
*
\*/
#ifndef __FORM__
#define __FORM__
#include <string>
#include <cctype> /* isspace */
#include <sstream> /* stringstream */
#include <cstdint>
/* Push the values in a register to a string */
static
void
reg_to_string(uint32_t reg, std::stringstream & str)
{
for(int32_t i = 0; i <= 3; i++)
str << ((char*)®)[i];
}
/* Reduce multiple whitespaces to a single whitepace */
static
std::string
whitespace_reduce(std::string str)
{
uint32_t index;
while ((index = str.find(" ")) != std::string::npos)
str.erase(index, 1);
return str;
}
/* Remove leading whitespace */
static
std::string
trim_l(std::string str)
{
while (std::isspace(*str.begin()))
str.erase(str.begin());
return str;
}
#endif /* __FORM__ */