00001 /* 00002 FALCON - The Falcon Programming Language. 00003 FILE: autowstring.h 00004 00005 SUtility to convert falcon items and strings into C Strings. 00006 ------------------------------------------------------------------- 00007 Author: Giancarlo Niccolai 00008 Begin: sab ago 4 2007 00009 00010 ------------------------------------------------------------------- 00011 (C) Copyright 2004: the FALCON developers (see list in AUTHORS file) 00012 00013 See LICENSE file for licensing details. 00014 */ 00015 00021 #ifndef flc_autowstring_H 00022 #define flc_autowstring_H 00023 00024 #include <falcon/setup.h> 00025 #include <falcon/types.h> 00026 #include <falcon/string.h> 00027 00028 namespace Falcon { 00029 00030 class Item; 00031 class VMachine; 00032 00033 00040 class FALCON_DYN_CLASS AutoWString 00041 { 00042 typedef enum { 00043 AutoWString_BUF_SPACE = 128 00044 } e_consts; 00045 00046 wchar_t *m_pData; 00047 wchar_t m_buffer[AutoWString_BUF_SPACE]; 00048 uint32 m_len; 00049 00050 void init_vm_and_format( VMachine *vm, const Item &itm, const String &fmt ); 00051 00052 00053 public: 00054 AutoWString( const Falcon::String &str ); 00055 00056 AutoWString( const Falcon::Item &itm ); 00057 00058 AutoWString( Falcon::VMachine *vm, const Falcon::Item &itm ): 00059 m_pData( 0 ) 00060 { 00061 init_vm_and_format( vm, itm, "" ); 00062 } 00063 00064 AutoWString( Falcon::VMachine *vm, const Falcon::Item &itm, const Falcon::String &fmt ): 00065 m_pData( 0 ) 00066 { 00067 init_vm_and_format( vm, itm, fmt ); 00068 } 00069 00070 ~AutoWString(); 00071 00072 const wchar_t *w_str() const { return m_pData; } 00073 operator const wchar_t *() const { return m_pData; } 00074 bool isValid() const { return m_pData[0] != (wchar_t) 0xFFFF; } 00075 00079 uint32 length() const { return m_len; } 00080 }; 00081 00082 } 00083 00084 #endif 00085 00086 /* end of autowstring.h */