// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // CSTR30.H // String Studio 3.0 // 20.june.1995 // ®HEXANET, COPYRIGHT HEXANET 1993-1995, ALL RIGHTS RESERVED // You can distribute this file as long as you distribute // the full CSTR package ( not the CSTR30A.CPP nor CSTR30B.CPP files! ) // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // To compile: use the String Studio STDAFX.H template and copy the necessary // #include to the STDAFX.H file of your current project. Then link with // CSTR30W.LIB (for Win16) or CSTR30NT.LIB for Win95/NT. You must not use _DEBUG with // these evaluation LIB files. See CSTR.HLP for details. // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // If you are a registered user, you will define _REGISTERED in your STDAFX.H precompiled header before // you compile this file and the String Studio *.CPP files to avoid the nag screens. // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #ifndef __cplusplus #error require C++ compilation (use a .cpp suffix) #endif #ifndef _CSTR #define _CSTR #endif #ifndef _CSTR30 #define _CSTR30 #endif #ifndef _CMEM #define _CMEM #endif #ifndef _CMEM30 #define _CMEM30 #endif // ----------------------------------------------------------------------- // You can build different String Studio versions // With or without the following components // (to remove some parts, put // before #define): #define _CSTR30_HASMOREBASIC #define _CSTR30_HASFILE #define _CSTR30_HASINI #define _CSTR30_HASWINCTL #define _CSTR30_HASNUM #define _CSTR30_HASCTIM #define _CSTR30_HASCFFIND #define _CSTR30_HASUNC #define _CSTR30_HASCTL3D #define _CSTR30_HASFINDWORD #define _CSTR30_HASCHAR #ifdef _CSTR30_HASWINCTL #ifndef _WINDOWS #undef _CSTR30_HASWINCTL #endif #endif #ifdef _CSTR30_HASNUM #ifndef _CSTR30_HASCHAR #define _CSTR30_HASCHAR #endif #endif #ifdef _WIN32 #ifdef _CSTR30_HASFILE #ifndef _CSTR30_HASCFFIND #define _CSTR30_HASCFFIND #endif #endif #endif #ifdef _CSTR30_HASCFFIND #ifndef _CSTR30_HASCTIM #define _CSTR30_HASCTIM #endif #ifndef _CSTR30_HASFILE #define _CSTR30_HASFILE #endif #endif // Tell us which components we are using... #ifndef _ALREADY_DISPLAYED #ifdef _CSTR30_HASMOREBASIC #pragma message("String Studio 3.0: adding MOREBASIC functions group.") #endif #ifdef _CSTR30_HASFILE #pragma message("String Studio 3.0: adding FILE functions group.") #endif #ifdef _CSTR30_HASINI #pragma message("String Studio 3.0: adding INI functions group.") #endif #ifdef _CSTR30_HASWINCTL #pragma message("String Studio 3.0: adding WINCTL functions group.") #endif #ifdef _CSTR30_HASNUM #pragma message("String Studio 3.0: adding NUM functions group.") #endif #ifdef _CSTR30_HASCTIM #pragma message("String Studio 3.0: adding CTIM functions group.") #endif #ifdef _CSTR30_HASCFFIND #pragma message("String Studio 3.0: adding CFFIND functions group.") #endif #ifdef _CSTR30_HASUNC #pragma message("String Studio 3.0: adding UNC functions group.") #endif #ifdef _CSTR30_HASCTL3D #pragma message("String Studio 3.0: adding CTL3D functions group.") #endif #ifdef _CSTR30_HASFINDWORD #pragma message("String Studio 3.0: adding FINDWORD functions group.") #endif #ifdef _CSTR30_HASCHAR #pragma message("String Studio 3.0: adding CHAR functions group.") #endif #endif // _ALREADY_DISPLAYED #ifndef LPTSTR #define LPTSTR LPSTR #endif #ifndef LPCTSTR #define LPTCSTR LPCSTR #endif // ----------------------------------------------------------------------- // Old MFCs will use CStr::Format #if _MFC_VER < 0x0252 #ifndef _ALREADY_DISPLAYED #pragma message("You are using an old MFC verion...") #endif #define _OLD_MFC #endif #ifdef _DOS #define _REGISTERED // No nag screen with DOS... #define TA_LEFT 0x0000 #define TA_RIGHT 0x0002 #define TA_CENTER 0x0006 #ifndef _ALREADY_DISPLAYED #pragma error( "Sorry: DOS no more supported!") #endif #else #ifndef _ALREADY_DISPLAYED #ifdef _WIN32 #ifdef _REGISTERED #pragma message("String Studio 3.0 (REGISTERED): Using the Win32 version...") #else #pragma message("String Studio 3.0 (UNREGISTERED): Using the Win32 version...") #endif #else #ifdef _REGISTERED #pragma message("String Studio 3.0 (REGISTERED): Using the Win16 version...") #else #pragma message("String Studio 3.0 (UNREGISTERED): Using the Win16 version...") #endif #endif #endif // _ALREADY_DISPLAYED #endif #ifndef _WIN32 // ---> Win32 file attributes (we use them instead of the DOS 16 attrib) #define FILE_ATTRIBUTE_READONLY 0x00000001 #define FILE_ATTRIBUTE_HIDDEN 0x00000002 #define FILE_ATTRIBUTE_SYSTEM 0x00000004 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 #define FILE_ATTRIBUTE_NORMAL 0x00000080 #endif class CStr; // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // AFX global functions // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------- // infos // ---------------------------------------------------------------------- #ifdef _WINDOWS #define FREERES_GLOBAL 0 // System #define FREERES_USER 1 #define FREERES_GDI 2 #define FREERES_MEM 3 #define FREERES_DISK 4 // in Kb. #ifdef _CSTR30_HASMOREBASIC extern UINT AfxGetFreeResRate( int iResCode ); extern unsigned long AfxGetFreeResValue( int iResCode ); #endif // _CSTR30_HASMOREBASIC extern BOOL AfxHasWin4Look(); // 3.0 #ifdef _CSTR30_HASINI extern int AfxGetPrecision(); extern CStr AfxGetDecimalPoint(); extern CStr AfxGetThousandsSeparator(); extern CString AfxGetShortDateFormat(); extern CString AfxGetLongDateFormat(); #endif // _CSTR30_HASINI // ---------------------------------------------------------------------- // windows specific // ---------------------------------------------------------------------- extern void AfxSleep(int iSecs, BOOL bBackGnd = TRUE ); // 3.0 extern void AfxGiveTheHand( HWND hDialog = NULL ); // 3.0 #ifdef _CSTR30_HASCTL3D // Ctl3D ( release 2.0 only ) wrappers for the TRUE MFC applications #define AFXCTL3D_OK 0 // Ok to use CTL3D #define AFXCTL3D_NOTFOUND 1 // The user doesn' t own the DLL (CTL3DV2.DLL or CTL3D32.DLL) #define AFXCTL3D_BADDLL 2 // Error #define AFXCTL3D_ERROR 3 // Error #ifndef CTL3D_ALL #define CTL3D_ALL 0xffff #endif extern "C" int AfxCtl3dLoad( ); // 3.0 extern "C" BOOL AfxCtl3dUnload( ); extern "C" BOOL AfxCtl3dNewColors( ); extern "C" BOOL AfxCtl3dSubclassCtl( HWND hItem ); // 3.0 #endif // _CSTR30_HASCTL3D #ifdef _CSTR30_HASINI extern BOOL AfxWriteWindowPos( HWND hWnd , BOOL bUseParent = FALSE, LPCTSTR szWindowName = "Main", LPCTSTR szIni = NULL ); extern RECT AfxGetWindowPos( HWND hWnd = NULL, LPCTSTR szWindowName = "Main", LPCTSTR szIni = NULL, BOOL bMove = TRUE, BOOL bSize = FALSE); #endif // _CSTR30_HASINI extern BOOL AfxCenterWindow( CWnd* pWnd, BOOL bAbsolute = TRUE ); #ifdef _CSTR30_HASWINCTL // Maybe the following functions will simplify your MFC dialogs programming... extern BOOL AfxEnableDlgItem( CWnd* pWnd, UINT id = 1, BOOL bEnabled = TRUE ); extern BOOL AfxEnableOK( CWnd* pWnd, BOOL bEnabled = TRUE); extern BOOL AfxEnableCANCEL( CWnd* pWnd, BOOL bEnabled = TRUE); extern void AfxSetFocus( CWnd* pWnd, UINT id = 1 ); extern void AfxSetDefButton( CWnd* pWnd, UINT id = 1); extern void AfxActivateEdit( CWnd* pWnd, UINT id ); #endif // _CSTR30_HASWINCTL // ---------------------------------------------------------------------- // files // ---------------------------------------------------------------------- #ifdef _CSTR30_HASCTIM extern BOOL AfxSetFileTime( LPCTSTR szSrcFile, LPCTSTR szDestFile ); // 3.0 extern BOOL AfxTouchFile( LPCTSTR szFile ); // 3.0 extern BOOL AfxSetFileAttributes( LPCTSTR szSrcFile, LPCTSTR szDestFile ); // 3.0 #endif // _CSTR30_HASCTIM #endif // windows // ---------------------------------------------------------------------- // misc // ---------------------------------------------------------------------- #define AfxRoundToInt(x) floor((x)+0.5) #ifdef _CSTR30_HASNUM extern double AfxRound( double x, int precision = 2); #endif // _CSTR30_HASNUM #ifdef _CSTR30_HASFINDWORD extern BOOL AfxFindWordInFile( LPCTSTR szFile, LPCTSTR szWord, unsigned long iFromLine = 0L, int iFromCursor = 0, unsigned long* rLineValue = NULL, int* rCursorValue =NULL, BOOL bExact = TRUE, BOOL bMatchCase = FALSE ); #endif // _CSTR30_HASWFINDWORD extern BOOL AfxCheckFileName( CString& sValue, BOOL bNoWildCards = TRUE); extern BOOL AfxIsDateValid( int iYear, int iMonth, int iDay ); // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // class CMem [3.0] // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #ifdef _WINDOWS class CMem // 3.0 { public: CMem (); CMem (DWORD dwSize, UINT uFlags = GHND); ~CMem (); void __far * Alloc (DWORD dwSize, UINT uFlags = GHND); void __far * ReAlloc (DWORD dwSize, UINT uFlags = GHND); void Free (); HGLOBAL GetHandle () {return (m_hGlb); }; DWORD GetSize () {return (m_dwSize); }; void __far * GetPtr() {return ((void __far *) ((char __far *)m_pvMem)); }; BOOL IsValid() { return ( (m_hGlb != NULL) && ( m_dwSize >= m_dwRequest )); }; protected: HGLOBAL m_hGlb; void __far * m_pvMem; DWORD m_dwSize, m_dwRequest; }; #endif // _WINDOWS // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // class CStr // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- typedef signed long SLong; #define COPYTO_SUCCESS 0 #define COPYTO_NOTFOUND 1 #define COPYTO_BADSRCFNAME 2 #define COPYTO_BADDESTFNAME 3 #define COPYTO_NOMEM 4 #define COPYTO_CANTCREATEDEST 5 #define COPYTO_READERROR 6 #define COPYTO_WRITEERROR 7 #define COPYTO_DISKFULL 8 #define COPYTO_CANTDELETEDEST 9 #define COPYTO_NOATTRIB 10 // more a warning than an error code #define COPYTO_NODATE 11 // more a warning than an error code #define COPYTO_CANTDELETESRC 12 // more a warning than an error code class CStr : public CString { public: // ---------------------------------------------------------- // Constructors // ---------------------------------------------------------- #ifdef _REGISTERED CStr( void ): CString( ) {}; CStr( const CString& stringSrc): CString( stringSrc ) {}; CStr( char ch, int nRepeat = 1): CString(ch, nRepeat ) {}; CStr( const char* psz): CString( psz ) {}; CStr( const char* pch, int nLength): CString( pch, nLength ) {}; #ifdef _WINDOWS CStr( UINT iStringID, HINSTANCE hInstance = NULL ): CString() { if ( hInstance == NULL ) this->LoadString ( (UINT)iStringID); else { ::LoadString( hInstance, (UINT)iStringID, this->GetBuffer(256), 256 ); this->ReleaseBuffer(); } }; #endif #else CStr( void ); CStr( const CString& stringSrc); CStr( char ch, int nRepeat = 1); CStr( const char* psz); CStr( const char* pch, int nLength); #ifdef _WINDOWS CStr( UINT iStringID, HINSTANCE hInstance = NULL ); #endif #endif // ---------------------------------------------------------- // Basics // ---------------------------------------------------------- CString Trim( void ); // 3.0: Now deletes CR and LF codes CString TrimBegin( void ); CString TrimEnd( void ); unsigned int Count( LPCTSTR szSubString ) const; unsigned int Count( char szSubString ) const; #ifdef _CSTR30_HASMOREBASIC CStr Align( int aMode, int iSize ); #endif CStr ExtractToEnd( int iFrom, char szSeparator ); CStr ExtractToEnd( int iFrom, LPCTSTR szSeparator = ";" ); CStr ExtractToBegin( int iFrom, char szSeparator ); CStr ExtractToBegin( int iFrom, LPCTSTR szSeparator = ";" ); CStr Delete( unsigned PFirst = 0, unsigned Plength = 0 ); CStr Replace( LPCTSTR szOld, LPCTSTR szNew = "" ); CStr Replace( char szOld, char szNew ); CStr Insert( LPCTSTR szSub, int Pos = 0 ); CStr Insert( char szSub, int Pos = 0 ); CStr Extract( int Pos = 1, LPCTSTR szDelimit = "\t" ); CStr Extract( int Pos, char szDelimit ); char& operator() (int Index ); // new 2.0: Replace the [] operator virtual LPTSTR CStr::GetBuffer( int size = 0); #ifdef _CSTR30_HASMOREBASIC CStr FirstUpper( void ); CStr Blank( void ); CStr Replicate( char cMotif = ' ', int iLen = 1 ); #endif // _CSTR30_HASMOREBASIC CStr AddLF( void ); CStr CheckSize( int iLength = 255, BOOL bAddPoints = TRUE ); CStr CheckDirSize( int iLength = 60, BOOL bShift = TRUE ); // ---------------------------------------------------------- // Basics - Windows specific // ---------------------------------------------------------- #ifdef _WINDOWS CStr FromRes( UINT iStringID, HINSTANCE hInstance = NULL, LPCTSTR szItem1 = NULL, LPCTSTR szItem2 = NULL, LPCTSTR szItem3 = NULL, LPCTSTR szItem4 = NULL, LPCTSTR szItem5 = NULL, LPCTSTR szItem6 = NULL, LPCTSTR szItem7 = NULL, LPCTSTR szItem8 = NULL, LPCTSTR szItem9 = NULL ); #ifdef _CSTR30_HASMOREBASIC #ifndef _WIN32 int GetTextWidth( HDC hDC, int iTabCount = 0, int far* pTabList = NULL ) const; int GetTextHeight( HDC hDC , int iTabCount = 0, int far* pTabList = NULL ) const; #endif // !_WIN32 int GetTextWidth( CDC* pDC , int iTabCount = 0, int far* pTabList = NULL ) const; int GetTextWidth( CWnd* pWnd , int iTabCount = 0, int far* pTabList = NULL ) const; int GetTextHeight( CDC* pDC , int iTabCount = 0, int far* pTabList = NULL ) const; int GetTextHeight( CWnd* pWnd , int iTabCount = 0, int far* pTabList = NULL ) const; #endif // _CSTR30_HASMOREBASIC CStr GetWindowTitle( CWnd* pWnd, BOOL bIncDocName = FALSE ); CStr GetWindowTitle( HWND hWnd, BOOL bIncDocName = FALSE ); #ifdef _CSTR30_HASMOREBASIC CSize TabbedTextOut( CDC* pDC, int X, int Y, int iTabCount = 0, int far* TabList = NULL ) const; CSize TabbedTextOut( CWnd* pWnd, int X, int Y, int iTabCount = 0, int far* TabList = NULL ) const; int GetClassName( CWnd* pWnd ); int GetClassName( HWND hWnd ); #endif CStr GetWinfileAssociation( LPCTSTR szExtension ); int MB( CWnd* pWnd = NULL, LPCTSTR szTitle = NULL, UINT mbType = MB_OK | MB_ICONINFORMATION ) const; #ifdef _CSTR30_HASWINCTL int GetDlgItemText( CWnd* pWnd, UINT iControl ); void ToCtl( CWnd* pWnd, int iCtl, BOOL bAltMode = FALSE ) const; CStr FromCtl( CWnd* pWnd, int iCtl ); #endif // _CSTR30_HASWINCTL CStr sprintf( LPCTSTR szFormat, ... ); // 3.0 #endif // _WINDOWS // ---------------------------------------------------------- // Nums // ---------------------------------------------------------- #ifdef _CSTR30_HASNUM CString From( long data, int base = 10, LPCTSTR szSeparator = ","); CString From( unsigned long data, int base = 10, LPCTSTR szSeparator = ","); CString From( int data, int base = 10, LPCTSTR szSeparator = ","); CString From( unsigned int data, int base = 10, LPCTSTR szSeparator = ","); // 2.0 CString From( double data, int precision = 2, LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." ); CStr NumFormat( double dValue, LPCTSTR szFormat = "###,###,###,###.00;-###,###,###,###.00; ", LPCTSTR szDecimalPoint = ".", LPCTSTR szThousandSeparator ="," ); CStr NumUnformat( LPCTSTR szDecimalPoint = "." ); signed int ToInt( LPCTSTR szSeparator = ",") const; UINT ToUINT( LPCTSTR szSeparator = ",") const; signed long ToLong( LPCTSTR szSeparator = ",") const; unsigned long ToULong( LPCTSTR szSeparator = ",") const; float ToFloat( LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." ) const; double ToDouble( LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." ) const; CStr Round( LPCTSTR szDecimalPoint = "."); BOOL IsDigit( LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." ) const; BOOL IsInRange( double dMini = 0, double dMaxi = 100 ) const; #endif // _CSTR30_HASNUM // ---------------------------------------------------------- // Files // ---------------------------------------------------------- #ifdef _CSTR30_HASFILE BOOL IsFileName( BOOL bAllowWildCards = FALSE ) const; BOOL IsPathName( ) const; BOOL IsFullFileName( BOOL bNoWildCards = TRUE ) const; CStr GetPathValue( ); CStr GetFileNameValue( ); CStr CheckFullFileName( BOOL bNoWildCards = TRUE, BOOL bAddSlash =FALSE); CStr CheckFileExtension( LPCTSTR szExtension, BOOL bForceExtension = FALSE); BOOL ChDir( BOOL bIncludesFName = FALSE, BOOL bCreateDir = FALSE) const; BOOL MkDir( BOOL bIncFile = FALSE) const; BOOL RemoveDir( BOOL bIncFile = FALSE, BOOL bDeleteRO = TRUE ) const; // 3.0 BOOL DoesFileExist( ) const; BOOL DoesDirExist( BOOL bIncFile = FALSE) const; DWORD GetFileAttributes( ) const; // 3.0 BOOL IsRDOnly( ) { return (BOOL)( CStr::GetFileAttributes() & FILE_ATTRIBUTE_READONLY ); }; // 3.0 BOOL SetFileAttributes( DWORD dwNewAttrib ) const; // 3.0 unsigned long GetFileSize( unsigned long* pulSizeInBytes = NULL ) const; // 3.0 BOOL DeleteFile( BOOL bDeleteRO = TRUE ) const; // 3.0 BOOL IsWriteable( long lBytes = 0L ) const; // 3.0 long GetDiskFreeSpace( ) const; // 3.0 #ifdef _WINDOWS BOOL CreateFile( UINT uiWin16Attrib = OF_SHARE_COMPAT ) const; // 3.0 #ifdef _WINDLL int CopyTo( LPCTSTR szDestFile, BOOL bDeleteDest = TRUE, BOOL bChangeDate = TRUE, BOOL bChangeAttrib = TRUE , BOOL bDeleteSrc = FALSE, int iBufferSize = 4096 ) const; // 3.0 #else int CopyTo( LPCTSTR szDestFile, BOOL bDeleteDest = TRUE, BOOL bChangeDate = TRUE, BOOL bChangeAttrib = TRUE , BOOL bDeleteSrc = FALSE, int iBufferSize = 16384 ) const; // 3.0 #endif #endif // _WINDOWS #ifdef _WINDOWS CStr GetAppDir( LPCTSTR szAppName = NULL ); CStr GetWinDir( ); CStr GetWinSysDir( ); #endif CStr GetThisDir( ); CStr GetTempFileName( ); CStr GetTempDir(); CStr FromFile( LPCTSTR szFile, BOOL bKeepString = FALSE, BOOL bAddPoints = TRUE ); BOOL ToFile( LPCTSTR szFile, BOOL bAppend = TRUE ) const; #endif // _CSTR30_HASFILE // ---------------------------------------------------------- // Single char operation // ---------------------------------------------------------- #ifdef _CSTR30_HASCHAR // Character informations BOOL IsCharUpper( int iIndex = 0) const; BOOL IsCharLower( int iIndex =0) const; BOOL IsCharAlpha( int iIndex =0) const; BOOL IsCharAlphaNum( int iIndex =0) const; BOOL IsCharNumeric( int iIndex =0) const; BOOL IsSpace( int iIndex =0) const; CStr MakeCharUpper( int iIndex =0); CStr MakeCharLower( int iIndex =0); #endif // _CSTR30_HASCHAR // ---------------------------------------------------------- // Find a word // ---------------------------------------------------------- #ifdef _CSTR30_HASFINDWORD int FindWord( LPCTSTR szWord, int iFrom = 0, BOOL bExact = TRUE, BOOL bMatchCase =FALSE) const; BOOL FindWordInMultilineBuffer( LPCTSTR szWord, unsigned long iFromLine = 0L, int iFromCursor = 0, unsigned long* rLineValue = NULL, int* rCursorValue = NULL, BOOL bExact = TRUE, BOOL bMatchCase =FALSE ) const; #endif // _CSTR30_HASFINDWORD // ---------------------------------------------------------- // Time // ---------------------------------------------------------- #ifdef _CSTR30_HASMOREBASIC #if !defined(_AFXDLL) && !defined(_USRDLL) CString From( CTime& TimeValue, LPCTSTR szFilter = "%m/%d/%y" ); // put %d/%m/%y if you' re french... CString FromCurrentTime( LPCTSTR szFilter = "%m/%d/%y" ); // put %d/%m/%y if you' re french... #ifdef _CSTR30_HASCTIM CString FromFileTime( LPCTSTR szFile, LPCTSTR szFilter = "%m/%d/%y" ); // put %d/%m/%y if you' re french... #endif // _CSTR30_HASCTIM #else #ifndef _ALREADY_DISPLAYED #pragma message("String Studio 3.0: Some CStr CTime functions not available with _AFXDLL or _USRDLL!") #endif #endif // WARNING: the function use M instead of m for the month, others parameters // are the same than _strftime C runtime function, and ToTime supports: [ D, Y, y, S ] CTime ToTime( LPCTSTR szFilter = "M/D/Y" ) const; // put y io. Y to use a date without century specification, put D/M/Y if you' re french... #endif // _CSTR30_HASMOREBASIC // ---------------------------------------------------------- // INI files // ---------------------------------------------------------- #ifdef _CSTR30_HASINI CStr FromIni( LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFile = NULL, int iSize = 512 ); void ToIni( LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFile = NULL ) const; #endif // _CSTR30_HASINI // ---------------------------------------------------------- // UNC files names // ---------------------------------------------------------- #ifdef _WINDOWS #ifdef _CSTR30_HASUNC BOOL IsUNC( ) const; // 3.0 CStr FilenameToUNC( ); // 3.0 (not implemented) CStr UNCToFilename( ); // 3.0 (not implemented) #endif // _CSTR30_HASUNC #endif // _WINDOWS // don' t call the following functions! -------------------------------------------------------------------------------- protected: LPTSTR TrimTout( LPTSTR str ); // TrimAll LPTSTR TrimAuDebut( LPTSTR str ); // TrimBegin LPTSTR TrimALaFin( LPTSTR str ); // TrimEnd char GarbageChar; #ifdef _CSTR30_HASNUM void FromDouble( LPTSTR pStr, double data, int precision, LPCTSTR szDecimalPoint = "." ); CStr NumberFormat( LPCTSTR szSeparator = ",", LPCTSTR szDecimalPoint = "." ); void NumFormatLPSTR( LPTSTR szFormat, LPTSTR szFResult, double dValue, LPCTSTR szDecimalPoint = ".", LPCTSTR szThousandSeparator = ","); #endif // _CSTR30_HASNUM #ifdef _CSTR30_HASFILE void DeleteADir(char far *path, BOOL bDeleteRO ) const; // 3.0 void RecurseDeleteDir(LPTSTR path, BOOL bDeleteRO ) const; // 3.0 #endif // _CSTR30_HASFILE }; // end of class CStr // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // class CTim // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #ifdef _CSTR30_HASCTIM #ifndef _CTIM #define _CTIM #endif #ifndef _CTIM30 #define _CTIM30 #endif #define CTIME_OK 0 #define CTIME_OVERFLOW 1 #define CTIME_NOTVALID 2 class CTim : public CTime { public: // ---------------------------------------------------------- // Constructors // ---------------------------------------------------------- CTim( void ) : CTime(1980, 1, 1, 0, 0, 0) {}; // we can' t use the standard constructor... CTim( const CTime& timeSrc ) : CTime( timeSrc ) {}; CTim( time_t time ) : CTime( time ) {}; CTim( int nYear, int nMonth, int nDay, int nHour = 0, int nMin = 0, int nSec = 0 ): CTime( nYear, nMonth, nDay, nHour, nMin, nSec ) {}; CTim( WORD wDosDate, WORD wDosTime ) : CTime( wDosDate, wDosTime ) {}; #ifdef _WIN32 CTim( const FILETIME& ft ) : CTime( ft ) {}; // 3.0 CTim( const SYSTEMTIME& ft ) : CTime( ft ) {}; // 3.0 #endif // ---------------------------------------------------------- // Actions // ---------------------------------------------------------- int Build( int iYear, int iMonth, int iDay, int iHour = 0, int iMin = 0, int iSec = 0 ); BOOL FromFile( LPCTSTR szFile ); BOOL ToFile( LPCTSTR szFile ) const; // 3.0 BOOL SetDay( int iDay = 1 ); //All these methods change the current CTim object... BOOL SetDay( LPCTSTR szDay ); BOOL SetMonth( int iMonth = 1 ); BOOL SetMonth( LPCTSTR szMonth ); BOOL SetYear( int iYear ); BOOL SetYear( LPCTSTR szYear ); BOOL SetSec( int iSec = 0 ); BOOL SetSec( LPCTSTR szSec ); BOOL SetMin( int iMin = 0 ); BOOL SetMin( LPCTSTR szMin ); BOOL SetHour( int iHour = 23 ); BOOL SetHour( LPCTSTR szHour ); BOOL IncDay( int iDay = 1 ); BOOL IncSec( int iSec = 1 ); BOOL IncMin( int iMin = 1 ); BOOL IncHour( int iHour = 1 ); // ---------------------------------------------------------- // Infos // ---------------------------------------------------------- BOOL IsValid() const; // 3.0 BOOL IsLeapYear( ) const; BOOL IsLastDay() const; // last day of the month }; // class CTim #endif // _CSTR30_HASCTIM #ifndef _ALREADY_DISPLAYED #define _ALREADY_DISPLAYED #endif // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // class CFFind // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #ifdef _CSTR30_HASCFFIND #ifndef _CFFIND #define _CFFIND #endif #ifndef _CFFIND30 #define _CFFIND30 #endif class CFFind // 3.0 { public: // ---------------------------------------------------------- // Constructors and destructors // ---------------------------------------------------------- CFFind() { lPos = 0L; m_strName = ""; m_win16Attrib = 0xff; #ifdef _WIN32 m_hFFind = INVALID_HANDLE_VALUE; #else m_hFFind = ENOENT; #endif }; CFFind( LPCTSTR szPath, UINT win16Attrib = 0xff ) { lPos = 0L; m_strName = szPath; m_win16Attrib = win16Attrib; #ifdef _WIN32 m_hFFind = INVALID_HANDLE_VALUE; #else m_hFFind = ENOENT; #endif }; ~CFFind() { #ifdef _WIN32 FindClose( m_hFFind ); #endif lPos = 0L; m_strName = ""; m_win16Attrib = 0xff; }; // ---------------------------------------------------------- // Actions // ---------------------------------------------------------- BOOL FindFirst(); BOOL FindNext(); BOOL Find(); void SetPath( LPCTSTR szPath, UINT win16Attrib = 0xff ) { lPos = 0L; m_strName = szPath; m_win16Attrib = win16Attrib; #ifdef _WIN32 m_hFFind = INVALID_HANDLE_VALUE; #else m_hFFind = ENOENT; #endif }; void Reset( ) { lPos = 0L; m_strName = ""; m_win16Attrib = 0xff; #ifdef _WIN32 m_hFFind = INVALID_HANDLE_VALUE; #else m_hFFind = ENOENT; #endif }; // ---------------------------------------------------------- // Informations // ---------------------------------------------------------- DWORD GetAttributes() const; void GetCreationTime( CTim* pTim ) const; void GetLastAccessTime( CTim* pTim ) const; void GetLastWriteTime( CTim* pTim ) const; DWORD GetSize() const; void GetShortName( LPTSTR szName ) const; void GetLongName( LPTSTR szName ) const; void GetFullShortName( LPTSTR szName ) const; void GetFullLongName( LPTSTR szName ) const; #ifdef _WINDOWS void GetShortName( CString& szName ) const; void GetLongName( CString& szName ) const; void GetFullShortName( CString& szName ) const; void GetFullLongName( CString& szName ) const; #endif protected: #ifdef _WIN32 WIN32_FIND_DATA m_fBuf; HANDLE m_hFFind; #else struct find_t m_fBuf; unsigned int m_hFFind; #endif unsigned int m_win16Attrib; long lPos; CStr m_strName; }; // class CFFind #endif // _CSTR30_HASCFFIND