DCL 4.0
Loading...
Searching...
No Matches
__strumbs.h File Reference

Go to the source code of this file.

Macros

#define __DCL_UNIX_WCS_H__   20110117
#define MBSTOSTR_ER(mbs, nmbs, str)
#define STRTOMBS(str, mbs)
#define STRTOMBS_ER(str, mbs)

Functions

__DCL_BEGIN_NAMESPACE String __mbstostr (const char *_src, size_t n=(size_t) -1) __DCL_THROWS1(CharsetConvertException *)
size_t __mbstostr_nt (const char *_mbs, size_t _nmbs, String &_str)
size_t __strtombs_nt (const String &_str, char *_mbs, size_t _nmbs)

Macro Definition Documentation

◆ __DCL_UNIX_WCS_H__

#define __DCL_UNIX_WCS_H__   20110117

Definition at line 2 of file __strumbs.h.

◆ MBSTOSTR_ER

#define MBSTOSTR_ER ( mbs,
nmbs,
str )
Value:
if (__mbstostr_nt(mbs, nmbs, str) == (size_t)-1) { \
errno = EILSEQ; \
return -1; \
}
size_t __mbstostr_nt(const char *_mbs, size_t _nmbs, String &_str)
Definition __strumbs.cpp:15

Definition at line 19 of file __strumbs.h.

19#define MBSTOSTR_ER(mbs, nmbs, str) \
20 if (__mbstostr_nt(mbs, nmbs, str) == (size_t)-1) { \
21 errno = EILSEQ; \
22 return -1; \
23 }

◆ STRTOMBS

#define STRTOMBS ( str,
mbs )
Value:
size_t n##mbs = __strtombs_nt(str, NULL, (size_t)-1); \
char* mbs = NULL; \
if (n##mbs != (size_t)-1) { \
mbs = (char*)alloca((n##mbs + 1) * sizeof(char)); \
n##mbs = __strtombs_nt(str, mbs, n##mbs + 1); \
}
size_t __strtombs_nt(const String &_str, char *_mbs, size_t _nmbs)
Definition __strumbs.cpp:27
#define NULL
Definition Config.h:340
void CharsetConvertException *size_t n
Definition SQLField.cpp:253

Definition at line 25 of file __strumbs.h.

25#define STRTOMBS(str, mbs) \
26 size_t n##mbs = __strtombs_nt(str, NULL, (size_t)-1); \
27 char* mbs = NULL; \
28 if (n##mbs != (size_t)-1) { \
29 mbs = (char*)alloca((n##mbs + 1) * sizeof(char)); \
30 n##mbs = __strtombs_nt(str, mbs, n##mbs + 1); \
31 }

◆ STRTOMBS_ER

#define STRTOMBS_ER ( str,
mbs )
Value:
STRTOMBS(str, mbs) \
else { \
errno = EILSEQ; \
return -1; \
}
#define STRTOMBS(str, mbs)
Definition __strumbs.h:25

Definition at line 33 of file __strumbs.h.

33#define STRTOMBS_ER(str, mbs) \
34 STRTOMBS(str, mbs) \
35 else { \
36 errno = EILSEQ; \
37 return -1; \
38 }

Function Documentation

◆ __mbstostr()

__DCL_BEGIN_NAMESPACE String __mbstostr ( const char * _src,
size_t n = (size_t) -1 )

UNIX에서 system call 관련 문자열들에 대한 wchar_t 처리

Definition at line 8 of file __strumbs.cpp.

10{
11 __DCL_ASSERT(_mbs != NULL);
12 return UTF8Decoder::decode(_mbs, _nmbs);
13}
#define __DCL_ASSERT(expr)
Definition Object.h:371

◆ __mbstostr_nt()

size_t __mbstostr_nt ( const char * _mbs,
size_t _nmbs,
String & _str )

Definition at line 15 of file __strumbs.cpp.

16{
17 try {
18 _str = __mbstostr(_mbs, _nmbs);
19 }
20 catch (CharsetConvertException* cause) {
21 cause->destroy();
22 return -1; // EILSEQ
23 }
24 return _str.length();
25}
__DCL_BEGIN_NAMESPACE String __mbstostr(const char *_mbs, size_t _nmbs) __DCL_THROWS1(CharsetConvertException *)
Definition __strumbs.cpp:8
virtual void destroy()
Definition Exception.cpp:74

◆ __strtombs_nt()

size_t __strtombs_nt ( const String & _str,
char * _mbs,
size_t _nmbs )

Definition at line 27 of file __strumbs.cpp.

28{
29 UTF8Encoder encoder(false);
30 if (_mbs == NULL) {
31 try {
32 return encoder.getEncodedLength(_str, _str.length());
33 }
34 catch (CharsetConvertException* cause) {
35 cause->destroy();
36 return -1; // EILSEQ
37 }
38 }
39
40 const wchar_t* pIn = _str;
41 size_t nInCount = _str.length();
42 size_t nOutCount = _nmbs;
43 int r = encoder.encode(pIn, nInCount, (byte_t*)_mbs, nOutCount);
44 if (r != CS_NOERROR)
45 return -1; // EILSEQ
46
47 if (nOutCount < _nmbs)
48 _mbs[nOutCount] = '\0';
49
50 return nOutCount;
51}
@ CS_NOERROR
Definition Charset.h:61
unsigned char byte_t
Definition Config.h:274
ByteString r