common_util
Loading...
Searching...
No Matches
sysutil.h
Go to the documentation of this file.
1
19#pragma once
20
21#include <cstdint>
22#include <string>
23
24namespace cutl
25{
26
31 enum class endian
32 {
34 little,
36 big,
37 };
38
43 enum class os_platform
44 {
52 os_unix,
55 };
56
63
69 std::string architecture();
70
78 std::string platform_name(os_platform type);
79
85 std::string cpp_stl_version();
86
92 uint16_t program_bit();
93
106 uint16_t byteswap(uint16_t value);
113 uint32_t byteswap(uint32_t value);
120 uint64_t byteswap(uint64_t value);
127 void byteswap(uint8_t *data, uint32_t size);
128
135 bool system(const std::string &cmd);
143 bool callcmd(const std::string &cmd, std::string &result);
151 std::string getenv(const std::string &name, const std::string &default_value);
152
158 std::string getcwd();
159
165 std::string homedir();
166
167} // namespace
std::string platform_name(os_platform type)
Get the platform name for the current operating system.
bool callcmd(const std::string &cmd, std::string &result)
Execute a system command and get the output.
std::string getenv(const std::string &name, const std::string &default_value)
Get an environment variable.
os_platform platform_type()
Get the platform type for the current operating system.
bool system(const std::string &cmd)
Execute a system command.
std::string cpp_stl_version()
Get the C++ standard library version.
endian endian_type()
Get the program endianness.
os_platform
Operating system platform type.
Definition sysutil.h:44
std::string homedir()
Get the home dir for the current user.
uint16_t byteswap(uint16_t value)
Byteswap a 16-bit value.
std::string architecture()
Get the architecture of the cpu processor(or operating system).
uint16_t program_bit()
Get the program bit.
std::string getcwd()
Get the working directory of the current excuting process.
endian
Endianness type.
Definition sysutil.h:32