38 opencc(
const char* config_file = NULL)
44 if (od != (opencc_t)-1) {
49 operator bool()
const {
50 return od != (opencc_t)-1;
53 int open(
const char* config_file) {
54 if (od != (opencc_t)-1) {
58 return (od == (opencc_t)-1) ? (-1) : (0);
61 int set_conversion_mode(opencc_conversion_mode conversion_mode) {
62 if (od == (opencc_t)-1) {
69 long convert(
const std::string& in, std::string& out,
long length = -1) {
70 if (od == (opencc_t)-1) {
77 if (outbuf == (
char*)-1) {
90 long convert(
const std::wstring& in, std::wstring& out,
long length = -1) {
91 if (od == (opencc_t)-1) {
94 size_t inbuf_left = in.length();
95 if ((length >= 0) && (length < (
long)inbuf_left)) {
98 const ucs4_t* inbuf = (
const ucs4_t*)in.c_str();
100 while (inbuf_left != 0) {
105 outbuf_left = inbuf_left + 64;
106 out.resize(count + outbuf_left);
107 outbuf = (ucs4_t*)out.c_str() + count;
109 &inbuf_left, &outbuf, &outbuf_left);
110 if (retval == (
size_t)-1) {
116 out.resize(count + 1);
121 opencc_error errno()
const {
125 void perror(
const char* spec =
"OpenCC")
const {
134 #endif // ifdef __cplusplus