ACE_Argv_Type_Converter Class Reference

To convert 'char' input/command line parameter to 'wchar_t'. More...

#include <Argv_Type_Converter.h>

List of all members.

Public Member Functions

 ACE_Argv_Type_Converter (int &argc, char **argv)
 ACE_Argv_Type_Converter (int &argc, wchar_t **argv)
 ~ACE_Argv_Type_Converter (void)
ACE_TCHAR ** get_TCHAR_argv (void)
 Returns the pointer of converted command line.
char ** get_ASCII_argv (void)
 Returns the pointer of ASCII (char) command line.
int & get_argc (void)
 Returns the number of sub parameters (argc).

Private Member Functions

 ACE_Argv_Type_Converter (const ACE_Argv_Type_Converter &)
 Copy Constructor should not be used.
ACE_Argv_Type_Converter operator= (const ACE_Argv_Type_Converter &)
 Assignment '=' operator should not be used.
void initialize (void)
 Perform common initialization for two Ctor's.
void align_char_with_wchar (void)
void align_wchar_with_char (void)
void cleanup (void)
 Clean up removed (comsumed) argv entries and reset the pass flags.

Private Attributes

int & saved_argc_
 Original number of input parameter, same as 'argc'.
char ** char_argv_
 Data member pointer that contains converted argv in ACE_ANTI_TCHAR.
wchar_t ** wchar_argv_
 Data member pointer that contains converted argv in ACE_TCHAR.
int before_pass_argc_
 argc value before any argv has been passed.
bool const original_type_
bool wchar_passed_
 true indicates wchar_t type argv has been passed.
bool char_passed_
 true indicates char type argv has been passed.

Detailed Description

To convert 'char' input/command line parameter to 'wchar_t'.

This class is to convert 'char' type command line parameter to wide-character (wchar_t) format and stores the copy of it. This is useful for all classes that use 'char**' argv but cannot be converted into 'ACE_TCHAR**' version. Note that the converted data will be lost upon destruction, so classes should use this class as their data member.

Definition at line 39 of file Argv_Type_Converter.h.


Constructor & Destructor Documentation

ACE_Argv_Type_Converter::ACE_Argv_Type_Converter ( int &  argc,
char **  argv 
)
ACE_Argv_Type_Converter::ACE_Argv_Type_Converter ( int &  argc,
wchar_t **  argv 
)
ACE_Argv_Type_Converter::~ACE_Argv_Type_Converter ( void   ) 

Definition at line 56 of file Argv_Type_Converter.cpp.

00057 {
00058 #if defined (ACE_USES_WCHAR)
00059   // selectively delete the 'copy' of argv
00060   if (this->original_type_)
00061     {
00062       // if original type is wchar_t
00063       if (this->char_passed_)
00064         this->align_wchar_with_char ();
00065 
00066       for (int i = 0; i < this->before_pass_argc_; ++i)
00067         ACE_OS::free (this->char_argv_[i]);
00068 
00069       delete [] this->char_argv_;
00070     }
00071   else
00072     {
00073       // if original type is char
00074       if (this->wchar_passed_)
00075         this->align_char_with_wchar ();
00076 
00077       for (int i = 0; i < this->before_pass_argc_; ++i)
00078         ACE_OS::free (this->wchar_argv_[i]);
00079 
00080       delete [] this->wchar_argv_;
00081     }
00082 #endif  // ACE_USES_WCHAR
00083 }

ACE_Argv_Type_Converter::ACE_Argv_Type_Converter ( const ACE_Argv_Type_Converter  )  [private]

Copy Constructor should not be used.


Member Function Documentation

void ACE_Argv_Type_Converter::align_char_with_wchar ( void   )  [private]

Align all entries in the char type argv list with wchar_t type argv list.

void ACE_Argv_Type_Converter::align_wchar_with_char ( void   )  [private]

Align all entries in the wchar_t type argv list with char type argv list.

void ACE_Argv_Type_Converter::cleanup ( void   )  [private]

Clean up removed (comsumed) argv entries and reset the pass flags.

int & ACE_Argv_Type_Converter::get_argc ( void   ) 

Returns the number of sub parameters (argc).

Definition at line 39 of file Argv_Type_Converter.inl.

00040 {
00041   return this->saved_argc_;
00042 }

char ** ACE_Argv_Type_Converter::get_ASCII_argv ( void   ) 

Returns the pointer of ASCII (char) command line.

Definition at line 24 of file Argv_Type_Converter.inl.

00025 {
00026 #if defined (ACE_USES_WCHAR)
00027   if (this->wchar_passed_)
00028     {
00029       this->align_char_with_wchar ();
00030     }
00031 
00032   this->char_passed_ = true;
00033 #endif  // ACE_USES_WCHAR
00034 
00035   return this->char_argv_;
00036 }

ACE_TCHAR ** ACE_Argv_Type_Converter::get_TCHAR_argv ( void   ) 

Returns the pointer of converted command line.

Definition at line 8 of file Argv_Type_Converter.inl.

00009 {
00010 #if defined (ACE_USES_WCHAR)
00011   if (this->char_passed_)
00012     {
00013       this->align_wchar_with_char ();
00014     }
00015 
00016   this->wchar_passed_ = true;
00017   return this->wchar_argv_;
00018 #else
00019   return this->char_argv_;
00020 #endif  // ACE_USES_WCHAR
00021 }

void ACE_Argv_Type_Converter::initialize ( void   )  [private]

Perform common initialization for two Ctor's.

ACE_Argv_Type_Converter ACE_Argv_Type_Converter::operator= ( const ACE_Argv_Type_Converter  )  [private]

Assignment '=' operator should not be used.


Member Data Documentation

argc value before any argv has been passed.

Definition at line 97 of file Argv_Type_Converter.h.

Data member pointer that contains converted argv in ACE_ANTI_TCHAR.

Definition at line 90 of file Argv_Type_Converter.h.

true indicates char type argv has been passed.

Definition at line 107 of file Argv_Type_Converter.h.

false represents original argv passed in is char, and true represents wchar_t.

Definition at line 101 of file Argv_Type_Converter.h.

Original number of input parameter, same as 'argc'.

Definition at line 87 of file Argv_Type_Converter.h.

Data member pointer that contains converted argv in ACE_TCHAR.

Definition at line 94 of file Argv_Type_Converter.h.

true indicates wchar_t type argv has been passed.

Definition at line 104 of file Argv_Type_Converter.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sat Nov 21 23:15:49 2009 for ACE by  doxygen 1.6.1