aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-06-10 13:40:32 +0800
committercrupest <crupest@outlook.com>2024-06-10 13:40:32 +0800
commit633c77d7cd2dd5cd22018aca17da1490e34d94ec (patch)
treeac007e9c84dbf662662f8b2ff06c2321945d2c6a /include
parent4725b4bc48722356fea4570ed7770137a0999491 (diff)
downloadcru-633c77d7cd2dd5cd22018aca17da1490e34d94ec.tar.gz
cru-633c77d7cd2dd5cd22018aca17da1490e34d94ec.tar.bz2
cru-633c77d7cd2dd5cd22018aca17da1490e34d94ec.zip
test: develop SubProcess test, fix various error.
NEED TEST: BufferStream, AutoReadStream, SubProcess.
Diffstat (limited to 'include')
-rw-r--r--include/cru/common/Buffer.h1
-rw-r--r--include/cru/common/String.h2
-rw-r--r--include/cru/common/SubProcess.h5
-rw-r--r--include/cru/common/io/Stream.h4
4 files changed, 10 insertions, 2 deletions
diff --git a/include/cru/common/Buffer.h b/include/cru/common/Buffer.h
index a03b69eb..2c3b7b87 100644
--- a/include/cru/common/Buffer.h
+++ b/include/cru/common/Buffer.h
@@ -7,6 +7,7 @@ class Buffer final {
friend void swap(Buffer& left, Buffer& right) noexcept;
public:
+ Buffer();
explicit Buffer(Index size);
Buffer(const Buffer& other);
diff --git a/include/cru/common/String.h b/include/cru/common/String.h
index 2156f060..5d9fc549 100644
--- a/include/cru/common/String.h
+++ b/include/cru/common/String.h
@@ -35,9 +35,11 @@ class CRU_BASE_API String {
public:
static String FromUtf8(const char* str);
static String FromUtf8(const char* str, Index size);
+ static String FromUtf8(const std::byte* str, Index size);
static String FromUtf8(std::string_view str) {
return FromUtf8(str.data(), str.size());
}
+ static String FromUtf8(const Buffer& buffer);
static String FromUtf16(const char16_t* str) { return String(str); }
static String FromUtf16(const char16_t* str, Index size) {
diff --git a/include/cru/common/SubProcess.h b/include/cru/common/SubProcess.h
index 0f87b184..1f7193b5 100644
--- a/include/cru/common/SubProcess.h
+++ b/include/cru/common/SubProcess.h
@@ -197,6 +197,11 @@ class CRU_BASE_API SubProcess : public Object {
CRU_DEFINE_CLASS_LOG_TAG(u"SubProcess")
public:
+ static SubProcess Create(
+ String program, std::vector<String> arguments = {},
+ std::unordered_map<String, String> environments = {});
+
+ public:
SubProcess(SubProcessStartInfo start_info);
CRU_DELETE_COPY(SubProcess)
diff --git a/include/cru/common/io/Stream.h b/include/cru/common/io/Stream.h
index 9f9807ae..014cd472 100644
--- a/include/cru/common/io/Stream.h
+++ b/include/cru/common/io/Stream.h
@@ -64,10 +64,10 @@ class CRU_BASE_API Stream : public Object {
Index Write(const char* buffer, Index offset, Index size);
Index Write(const char* buffer, Index size);
- virtual std::vector<std::byte> ReadAll();
+ virtual Buffer ReadToEnd(Index grow_size = 256);
// Utf8 encoding.
- String ReadAllAsString();
+ String ReadToEndAsUtf8String();
virtual void Flush();