Skip to content. Skip to navigation

ICTP Portal

Sections
You are here: Home Manuals on-line PGI Compiler pgC_lib ctype<char>
Personal tools
Document Actions

ctype<char>



Click on the banner to return to the class reference home page.

ctype<char>


ctype_base ctype<char> locale::facet

Summary

A specialization of the ctype facet.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

    Data Types
    id

Synopsis

#include <locale>
class ctype<char>; 

Description

This specialization of the ctype<charT> template provides inline versions of ctype's member functions. The facet provides the same public interface, and uses the same set of masks, as the ctype template.

Interface

template <>
class ctype<char> : public locale::facet, public ctype_base {
  public:
    typedef char char_type;
    explicit ctype(const mask* = 0, bool = false, 
                   size_t = 0);
    bool         is(mask, char) const;
    const charT* is(const char*, 
                    const char*, mask*) const;
    const charT* scan_is(mask,
                         const char*, 
                         const char*) const;
    const charT* scan_not(mask,
                          const char*, 
                          const char*) const;
    charT        toupper(char) const;
    const charT* toupper(char*, const charT*) const;
    charT        tolower(char) const;
    const charT* tolower(char*, const char*) const;
    charT        widen(char) const;
    const char*  widen(const char*, 
                     const char*, char*) const;
    char         narrow(char, char) const;
    const charT* narrow(const char*, const char*, 
                        char, char*) const;
    static locale::id id;
    static const size_t table_size = 256;

  protected:
    const mask* table() const throw();
    static const mask* classic_table() throw();

~ctype();  // virtual
    virtual charT        do_toupper(charT) const;
    virtual const charT* do_toupper(charT*, 
                                    const charT*) const;
    virtual charT        do_tolower(charT) const;
    virtual const charT* do_tolower(charT*, 
                                    const charT*) const;
};

Type

char_type

    Type of character the facet is instantiated on.

Constructors and Destructors

explicit ctype(const mask* tbl = 0, bool del = false,
               size_t refs = 0)

    Construct a ctype facet. The three parameters set up the following conditions:

    • The tbl argument must be either 0 or an array of at least table_size elements. If tbl is non zero then the supplied table will be used for character classification.

    • If tbl is non zero, and del is true then the tbl array will be deleted by the destructor, so the calling program need not concern itself with the lifetime of the facet.

    • If the refs argument is 0 then destruction of the object itself is delegated to the locale, or locales, containing it. This allows the user to ignore lifetime management issues. On the other had, if refs is 1 then the object must be explicitly deleted; the locale will not do so. In this case, the object can be maintained across the lifetime of multiple locales.

~ctype();  // virtual and protected

    Destroy the facet. If the constructor was called with a non-zero tbl argument and a true del argument, then the array supplied by the tbl argument will be deleted

Public Member Functions

The public members of the ctype<char> facet specialization do not all serve the same purpose as the functions in the template. In many cases these functions implement functionality, rather than just forwarding a call to a protected implementation function.

static const mask* 
classic_table() throw();

    Returns a pointer to a table_size character array that represents the classifications of characters in the "C" locale.

bool
is(mask m, charT c) const;

    Determines if the character c has the classification indicated by the mask m. Returns table()[(unsigned char)c] & m.

const charT* 
is(const charT* low, 
   const charT* high, mask* vec) const;

    Fills vec with every mask from ctype_base that applies to the range of characters indicated by [low,high). See ctype_base for a description of the masks. For instance, after the following call v would contain {alpha, lower, print,,alnum ,graph}:

      char a[] = "abcde";
      ctype_base::mask v[12];
      ctype<char>().do_is(a,a+5,v);
    

    This function returns high.

char         
narrow(charT c, char dfault) const;

    Returns c.

const charT* 
narrow(const charT* low, const charT*, char dfault,
       char* to) const;

    Performs ::memcpy(to,low,high-low). Returns high.

const charT* 
scan_is(mask m, const charT*, const charT* high) const;

    Finds the first character in the range [low,high) that matches the classification indicated by the mask m. The classification is matched by checking for table()[(unsigned char) p] & m, where p is in the range [low,high). Returns the first p that matches, or high if none do.

const charT* 
scan_not(mask m, const charT* low, const charT* high) const;

    Finds the first character in the range [low,high) that does not match the classification indicated by the mask m. The classification is matched by checking for !(table()[(unsigned char) p] & m), where p is in the range [low,high). Returns the first p that matches, or high if none do.

const mask* 
table() const throw();

    If the tbl argument that was passed to the constructor was non-zero, then this function returns that argument, otherwise it returns classic_table().

charT        
tolower(charT c) const;
const charT* 
tolower(charT* low, const charT* high) const;

    Returns do_tolower(c) or do_tolower(low,high).

charT        
toupper(charT) const;
const charT* 
toupper(charT* low, const charT* high) const;

    Returns do_toupper(c) or do_toupper(low,high).

charT        
widen(char c) const;

    Returns c.

const char*  
widen(const char* low, const char* high, charT* to) const;

    Performs ::memcpy(to,low,high-low. Returns high.

Facet ID

static locale::id id;

    Unique identifier for this type of facet.

Protected Member Functions

virtual charT        
do_tolower(charT) const;

    Returns the lower case representation of c, if such exists, otherwise returns c;

virtual const charT* 
do_tolower(charT* low, const charT* high) const;

    Converts each character in the range [low,high) to its lower case representation, if such exists. If a lower case representation does not exist then the character is not changed. Returns high.

virtual charT        
do_toupper(charT c) const;

    Returns the upper case representation of c, if such exists, otherwise returns c;

virtual const charT* 
do_toupper(charT* low, const charT* high) const;

    Converts each character in the range [low,high) to its upper case representation, if such exists. If an upper case representation does not exist then the character is not changed. Returns high.

See Also

locale, facets, collate, ctype<char>, ctype_byname


©Copyright 1996, Rogue Wave Software, Inc.


Powered by Plone This site conforms to the following standards: