Files
llgo/cpp/std/_wrap/string.cpp

44 lines
954 B
C++
Raw Normal View History

#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) {
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"