library: cpp/std; cpp/inih demo: inihreader

This commit is contained in:
xushiwei
2024-07-13 17:51:06 +08:00
parent dbecf33924
commit 80d80ad8aa
14 changed files with 363 additions and 129 deletions

View File

@@ -0,0 +1,43 @@
#include <string>
extern "C" {
// -----------------------------------------------------------------------------
void stdStringInitEmpty(std::string* s) {
new(s) std::string();
}
void stdStringInitFrom(std::string* s, std::string* v) {
new(s) std::string(*v);
}
void stdStringInitFromCStr(std::string* s, const char* cstr) {
new(s) std::string(cstr);
}
void stdStringInitFromCStrLen(std::string* s, const char* cstr, size_t len) {
new(s) std::string(cstr, len);
}
void stdStringDispose(const std::string* s) {
s->~basic_string();
}
// -----------------------------------------------------------------------------
const char* stdStringCStr(const std::string* s) {
return s->c_str();
}
const char* stdStringData(const std::string* s) {
return s->data();
}
size_t stdStringSize(const std::string* s) {
return s->size();
}
// -----------------------------------------------------------------------------
} // extern "C"