Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Macros | Typedefs | Functions | Variables
22.locale.ctype.narrow.cpp File Reference
#include <rw/_defs.h>
#include <locale>
#include <climits>
#include <clocale>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cwchar>
#include <cwctype>
#include <langinfo.h>
#include <rw_driver.h>
#include <rw_file.h>
#include <rw_locale.h>
Include dependency graph for 22.locale.ctype.narrow.cpp:

Go to the source code of this file.

Macros

#define LC_MESSAGES   _RWSTD_LC_MESSAGES
 
#define NLOOPS   25
 
#define MAX_STR_SIZE   16
 
#define LOCALES
 
#define BEGIN_LOCALE_LOOP(num, locname, loop_cntrl)
 
#define END_LOCALE_LOOP(locname)
 
#define ALPHA   std::ctype_base::alpha
 
#define UPPER   std::ctype_base::upper
 
#define LOWER   std::ctype_base::lower
 
#define DIGIT   std::ctype_base::digit
 
#define SPACE   std::ctype_base::space
 
#define CNTRL   std::ctype_base::cntrl
 
#define PUNCT   std::ctype_base::punct
 
#define XDIGIT   std::ctype_base::xdigit
 
#define GRAPH   std::ctype_base::graph
 
#define PRINT   std::ctype_base::print
 
#define STR(x)   #x
 
#define COND1(what)
 
#define COND3(what)
 

Typedefs

typedef unsigned char UChar
 

Functions

std::ctype_base::mask libc_mask (int mask, char ch, const char *locname)
 
bool libc_is (std::ctype_base::mask mask, char ch, const char *locname)
 
const char * narrow (char *dst, const char *src)
 
const char * widen (char *dst, const char *src)
 
char widen (char, char ch, const char *)
 
char narrow (char ch, const char *)
 
bool cond1 (std::ctype_base::mask mask, char ch, const char *locname)
 
bool cond3 (std::ctype_base::mask, char, const char *)
 
const char * narrow (char *dst, const wchar_t *src)
 
const wchar_t * widen (wchar_t *dst, const char *src)
 
std::ctype_base::mask libc_mask (int mask, wchar_t ch, const char *locname)
 
bool libc_is (std::ctype_base::mask mask, wchar_t ch, const char *locname)
 
wchar_t widen (wchar_t, char ch, const char *locname)
 
char narrow (wchar_t ch, const char *locname)
 
bool cond3 (std::ctype_base::mask mask, wchar_t ch, const char *locname)
 
template<class charT >
void test_narrow_widen (charT, const char *cname)
 
template<class charT >
void test_libc (charT, const char *cname)
 
template<class charT >
void test_libstd (charT, const char *cname)
 
template<class charT >
void run_test (charT, const char *cname)
 
int main (int argc, char *argv[])
 

Variables

const char * locale_root
 
const char * locale_list = 0
 

Macro Definition Documentation

◆ ALPHA

#define ALPHA   std::ctype_base::alpha

Definition at line 114 of file 22.locale.ctype.narrow.cpp.

◆ BEGIN_LOCALE_LOOP

#define BEGIN_LOCALE_LOOP (   num,
  locname,
  loop_cntrl 
)
Value:
for (const char* locname = locale_list; \
locname && *locname; locname += std::strlen (locname) + 1) { \
_TRY { \
const std::locale loc (locname); \
const std::ctype<char> &ctc = \
_STD_USE_FACET (std::ctype<char>, loc); \
_RWSTD_UNUSED (ctc); \
const std::ctype<charT> &ctp = \
_STD_USE_FACET (std::ctype<charT>, loc); \
for (int loop_cntrl = 0; loop_cntrl < int (num); loop_cntrl++)
#define loc
Definition 17.names.cpp:492
#define num
Definition 17.names.cpp:505
const char * locale_list
#define LOCALES
#define LC_CTYPE
#define _TRY
Definition _defs.h:850
_TEST_EXPORT char * rw_locale_query(int=_UNUSED_CAT, const char *=0, _RWSTD_SIZE_T=0)

Definition at line 89 of file 22.locale.ctype.narrow.cpp.

◆ CNTRL

#define CNTRL   std::ctype_base::cntrl

Definition at line 119 of file 22.locale.ctype.narrow.cpp.

◆ COND1

#define COND1 (   what)
Value:
if (!(ctc.is (what, c) || !ctp.is (what, ctp.widen (c)))) { \
rw_assert (!cond1 (what, c, locname), 0, __LINE__, \
"ctype<char>::is (" STR (what) ", %{#lc})" \
" || !ctype<%1$s>::is (" STR (what) ", " \
"ctype<%s>::widen (%{#lc}) = %{#lc})" \
" returned false in locale(%#s)", \
c, cname, c, ctp.widen (c), locname); \
} else (void)0
#define c
Definition 17.names.cpp:111
#define STR(x)
bool cond1(std::ctype_base::mask mask, char ch, const char *locname)

◆ COND3

#define COND3 (   what)
Value:
if ( ctp.narrow (ch, dfault) != dfault \
&& !(ctp.is (what, ch) || !ctc.is (what, ctp.narrow (ch, dfault)))) { \
rw_assert (!cond3 (what, ch, locname), 0, __LINE__, \
"ctype<%s>::is (" STR (what) ", %{#lc})" \
" || !ctype<char>::is (" STR (what) ", " \
"ctype<%1$s>::narrow (%{#lc}, %{#c}) = %{#lc})" \
" returned false in locale(%#s)", cname, ch, \
ch, dfault, ctp.narrow (ch, '\0'), \
locname); \
} else (void)0
bool cond3(std::ctype_base::mask, char, const char *)

◆ DIGIT

#define DIGIT   std::ctype_base::digit

Definition at line 117 of file 22.locale.ctype.narrow.cpp.

◆ END_LOCALE_LOOP

#define END_LOCALE_LOOP (   locname)
Value:
} \
_CATCH (...) { \
rw_assert (0, 0, __LINE__, \
"locale (\"%s\") threw an exception", locname); \
} \
}

Definition at line 102 of file 22.locale.ctype.narrow.cpp.

◆ GRAPH

#define GRAPH   std::ctype_base::graph

Definition at line 122 of file 22.locale.ctype.narrow.cpp.

◆ LC_MESSAGES

#define LC_MESSAGES   _RWSTD_LC_MESSAGES

22.locale.ctype.narrow.cpp - tests exercising the narrow() and widen() member functions of the ctype facet

$Id$

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2001-2008 Rogue Wave Software, Inc.

Definition at line 64 of file 22.locale.ctype.narrow.cpp.

◆ LOCALES

#define LOCALES
Value:
"{{en-US,de-DE,fr-FR,es-ES}-*-{ISO-8859-*,UTF-8,CP125?}," \
"{ja-JP-*-{EUC-JP,SHIFT_JIS,UTF-8,CP125?}}," \
"{zh-CN-*-{GB*,UTF-8,CP125?}}," \
"{ru-RU-*-{KOI*,UTF-8,CP125?}}}"

Definition at line 82 of file 22.locale.ctype.narrow.cpp.

◆ LOWER

#define LOWER   std::ctype_base::lower

Definition at line 116 of file 22.locale.ctype.narrow.cpp.

◆ MAX_STR_SIZE

#define MAX_STR_SIZE   16

Definition at line 80 of file 22.locale.ctype.narrow.cpp.

◆ NLOOPS

#define NLOOPS   25

Definition at line 79 of file 22.locale.ctype.narrow.cpp.

◆ PRINT

#define PRINT   std::ctype_base::print

Definition at line 123 of file 22.locale.ctype.narrow.cpp.

◆ PUNCT

#define PUNCT   std::ctype_base::punct

Definition at line 120 of file 22.locale.ctype.narrow.cpp.

◆ SPACE

#define SPACE   std::ctype_base::space

Definition at line 118 of file 22.locale.ctype.narrow.cpp.

◆ STR

#define STR (   x)    #x

◆ UPPER

#define UPPER   std::ctype_base::upper

Definition at line 115 of file 22.locale.ctype.narrow.cpp.

◆ XDIGIT

#define XDIGIT   std::ctype_base::xdigit

Definition at line 121 of file 22.locale.ctype.narrow.cpp.

Typedef Documentation

◆ UChar

typedef unsigned char UChar

Definition at line 112 of file 22.locale.ctype.narrow.cpp.

Function Documentation

◆ cond1()

bool cond1 ( std::ctype_base::mask  mask,
char  ch,
const char *  locname 
)

Definition at line 209 of file 22.locale.ctype.narrow.cpp.

◆ cond3() [1/2]

bool cond3 ( std::ctype_base::mask  mask,
wchar_t  ch,
const char *  locname 
)

Definition at line 412 of file 22.locale.ctype.narrow.cpp.

◆ cond3() [2/2]

bool cond3 ( std::ctype_base::mask  ,
char  ,
const char *   
)

Definition at line 250 of file 22.locale.ctype.narrow.cpp.

◆ libc_is() [1/2]

bool libc_is ( std::ctype_base::mask  mask,
char  ch,
const char *  locname 
)
inline

Definition at line 170 of file 22.locale.ctype.narrow.cpp.

◆ libc_is() [2/2]

bool libc_is ( std::ctype_base::mask  mask,
wchar_t  ch,
const char *  locname 
)

Definition at line 343 of file 22.locale.ctype.narrow.cpp.

◆ libc_mask() [1/2]

std::ctype_base::mask libc_mask ( int  mask,
char  ch,
const char *  locname 
)

Definition at line 128 of file 22.locale.ctype.narrow.cpp.

◆ libc_mask() [2/2]

std::ctype_base::mask libc_mask ( int  mask,
wchar_t  ch,
const char *  locname 
)

Definition at line 303 of file 22.locale.ctype.narrow.cpp.

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 721 of file 22.locale.ctype.narrow.cpp.

◆ narrow() [1/4]

const char * narrow ( char *  dst,
const char *  src 
)

Definition at line 177 of file 22.locale.ctype.narrow.cpp.

◆ narrow() [2/4]

const char * narrow ( char *  dst,
const wchar_t *  src 
)

Definition at line 258 of file 22.locale.ctype.narrow.cpp.

◆ narrow() [3/4]

char narrow ( char  ch,
const char *   
)

Definition at line 202 of file 22.locale.ctype.narrow.cpp.

◆ narrow() [4/4]

char narrow ( wchar_t  ch,
const char *  locname 
)

Definition at line 381 of file 22.locale.ctype.narrow.cpp.

◆ run_test()

template<class charT >
void run_test ( charT  ,
const char *  cname 
)

Definition at line 682 of file 22.locale.ctype.narrow.cpp.

◆ test_libc()

template<class charT >
void test_libc ( charT  ,
const char *  cname 
)

Definition at line 663 of file 22.locale.ctype.narrow.cpp.

◆ test_libstd()

template<class charT >
void test_libstd ( charT  ,
const char *  cname 
)

Definition at line 672 of file 22.locale.ctype.narrow.cpp.

◆ test_narrow_widen()

template<class charT >
void test_narrow_widen ( charT  ,
const char *  cname 
)

Definition at line 448 of file 22.locale.ctype.narrow.cpp.

◆ widen() [1/4]

const char * widen ( char *  dst,
const char *  src 
)

Definition at line 187 of file 22.locale.ctype.narrow.cpp.

◆ widen() [2/4]

char widen ( char  ,
char  ch,
const char *   
)

Definition at line 197 of file 22.locale.ctype.narrow.cpp.

◆ widen() [3/4]

const wchar_t * widen ( wchar_t *  dst,
const char *  src 
)

Definition at line 281 of file 22.locale.ctype.narrow.cpp.

◆ widen() [4/4]

wchar_t widen ( wchar_t  ,
char  ch,
const char *  locname 
)

Definition at line 350 of file 22.locale.ctype.narrow.cpp.

Variable Documentation

◆ locale_list

const char* locale_list = 0

Definition at line 87 of file 22.locale.ctype.narrow.cpp.

◆ locale_root

const char* locale_root

Definition at line 77 of file 22.locale.ctype.narrow.cpp.