Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Argv_Type_Converter.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Argv_Type_Converter.h
00006  *
00007  *  $Id: Argv_Type_Converter.h,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Si Mong Park <spark@ociweb.com>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_ARGV_TYPE_CONVERTER_H
00014 #define ACE_ARGV_TYPE_CONVERTER_H
00015 
00016 #include "ace/pre.h"
00017 
00018 #include "ace/ACE_export.h"
00019 #include "ace/OS_Memory.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 
00026 /**
00027  * @class ACE_Argv_Type_Converter
00028  *
00029  * @brief To convert 'char' input/command line parameter to 'wchar_t'.
00030  *
00031  * This class is to convert 'char' type command line paramter to
00032  * wide-character (wchar_t) format and stores the copy of it.
00033  * This is useful for all classes that use 'char**' argv but cannot
00034  * be converted into 'ACE_TCHAR**' version.
00035  * Note that the converted data will be lost upon destruction, so
00036  * classes should use this class as their data member.
00037  */
00038 class ACE_Export ACE_Argv_Type_Converter
00039 {
00040 public:
00041 
00042   ACE_Argv_Type_Converter (int &argc, char** argv);
00043 
00044 #if defined (ACE_USES_WCHAR)
00045   ACE_Argv_Type_Converter (int &argc, wchar_t** argv);
00046 #endif  // ACE_USES_WCHAR
00047 
00048   ~ACE_Argv_Type_Converter (void);
00049 
00050   /// Returns the pointer of converted command line.
00051   ACE_TCHAR** get_TCHAR_argv (void);
00052 
00053   /// Returns the pointer of ASCII (char) command line.
00054   char** get_ASCII_argv (void);
00055 
00056   /// Returns the number of sub paramters (argc).
00057   int& get_argc (void);
00058 
00059 private:
00060 
00061   /// Copy Constructor should not be used.
00062   ACE_Argv_Type_Converter (const ACE_Argv_Type_Converter&);
00063 
00064   /// Assignment '=' operator should not be used.
00065   ACE_Argv_Type_Converter operator= (const ACE_Argv_Type_Converter&);
00066 
00067 #if defined (ACE_USES_WCHAR)
00068 
00069   /// Perform common initialization for two Ctor's.
00070   void initialize (void);
00071 
00072   /// Align all entries in the char type argv list with wchar_t type
00073   /// argv list.
00074   void align_char_with_wchar (void);
00075 
00076   /// Align all entries in the wchar_t type argv list with char type
00077   /// argv list.
00078   void align_wchar_with_char (void);
00079 
00080   /// Clean up removed (comsumed) argv entries and reset the pass flags.
00081   void cleanup (void);
00082 #endif  // ACE_USES_WCHAR
00083 
00084 private:
00085   /// Original number of input paramter, same as 'argc'.
00086   int &saved_argc_;
00087 
00088   /// Data member pointer that contains converted argv in ACE_ANTI_TCHAR.
00089   char** char_argv_;
00090 
00091 #if defined (ACE_USES_WCHAR)
00092   /// Data member pointer that contains converted argv in ACE_TCHAR.
00093   wchar_t** wchar_argv_;
00094 
00095   /// argc value before any argv has been passed.
00096   int before_pass_argc_;
00097 
00098   /// FALSE represents original argv passed in is char, and TRUE
00099   /// represents wchar_t.
00100   const int original_type_;
00101 
00102   /// TRUE indicates wchar_t type argv has been passed.
00103   int wchar_passed_;
00104 
00105   /// TRUE indicates char type argv has been passed.
00106   int char_passed_;
00107 #endif  /* ACE_USES_WCHAR */
00108 };
00109 
00110 #if defined (__ACE_INLINE__)
00111 #include "ace/Argv_Type_Converter.inl"
00112 #endif  /* __ACE_INLINE__ */
00113 
00114 #include "ace/post.h"
00115 
00116 #endif  /* ACE_ARGV_TYPE_CONVERTER_H */

Generated on Mon Jun 16 11:19:04 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002