Skip to content

Commit 2a695d9

Browse files
committed
added function to convert char vector to string
1 parent d22ea37 commit 2a695d9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cpp-terminal/private/conversion.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
#include <cstdint>
44
#include <stdexcept>
55
#include <string>
6+
#include <vector>
7+
68
#ifdef _WIN32
79
#include <stdio.h>
810
#else
11+
912
#include <sys/ioctl.h>
13+
1014
#endif
1115

1216
namespace Term::Private {
@@ -93,6 +97,7 @@ inline std::string utf32_to_utf8(const std::u32string& s) {
9397
}
9498
return r;
9599
}
100+
96101
// coverts a string into an integer
97102
inline int convert_string_to_int(const char* string,
98103
const char* format,
@@ -107,4 +112,13 @@ inline int convert_string_to_int(const char* string,
107112
#endif
108113
}
109114

115+
// converts a vector of char into a string
116+
inline std::string vector_to_string(const std::vector<char>& vector) {
117+
std::string string;
118+
for (char i : vector) {
119+
string.push_back(i);
120+
}
121+
return string;
122+
}
123+
110124
} // namespace Term::Private

0 commit comments

Comments
 (0)