2024-07-13 17:51:06 +08:00
|
|
|
#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);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-13 18:11:34 +08:00
|
|
|
void stdStringDispose(std::string* s) {
|
2024-07-13 17:51:06 +08:00
|
|
|
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"
|