1 |
786 |
skrzyp |
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####
|
2 |
|
|
// -------------------------------------------
|
3 |
|
|
// This file is part of the eCos host tools.
|
4 |
|
|
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
|
5 |
|
|
//
|
6 |
|
|
// This program is free software; you can redistribute it and/or modify
|
7 |
|
|
// it under the terms of the GNU General Public License as published by
|
8 |
|
|
// the Free Software Foundation; either version 2 or (at your option) any
|
9 |
|
|
// later version.
|
10 |
|
|
//
|
11 |
|
|
// This program is distributed in the hope that it will be useful, but
|
12 |
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
// General Public License for more details.
|
15 |
|
|
//
|
16 |
|
|
// You should have received a copy of the GNU General Public License
|
17 |
|
|
// along with this program; if not, write to the
|
18 |
|
|
// Free Software Foundation, Inc., 51 Franklin Street,
|
19 |
|
|
// Fifth Floor, Boston, MA 02110-1301, USA.
|
20 |
|
|
// -------------------------------------------
|
21 |
|
|
// ####ECOSHOSTGPLCOPYRIGHTEND####
|
22 |
|
|
//===========================================================================
|
23 |
|
|
//#####DESCRIPTIONBEGIN####
|
24 |
|
|
//
|
25 |
|
|
// Author(s): sdf
|
26 |
|
|
// Contact(s): sdf
|
27 |
|
|
// Date: 1998/08/11
|
28 |
|
|
// Version: 0.01
|
29 |
|
|
// Purpose:
|
30 |
|
|
// Description: Interface to various global utility functions. Everything in this
|
31 |
|
|
// class is static (there are no instances).
|
32 |
|
|
// Requires:
|
33 |
|
|
// Provides:
|
34 |
|
|
// See also:
|
35 |
|
|
// Known bugs:
|
36 |
|
|
// Usage:
|
37 |
|
|
//
|
38 |
|
|
//####DESCRIPTIONEND####
|
39 |
|
|
//
|
40 |
|
|
//===========================================================================
|
41 |
|
|
#ifndef _UTILS_H
|
42 |
|
|
#define _UTILS_H
|
43 |
|
|
#include "FileName.h"
|
44 |
|
|
#define INCLUDEFILE <string>
|
45 |
|
|
#include "IncludeSTL.h"
|
46 |
|
|
#include <stdarg.h> // vsnprintf
|
47 |
|
|
|
48 |
|
|
class CUtils {
|
49 |
|
|
public:
|
50 |
|
|
static bool Launch (const CFileName &strFileName,const CFileName &strViewer);
|
51 |
|
|
static CString GetLastErrorMessageString ();
|
52 |
|
|
|
53 |
|
|
static bool AddToPath (const CFileName &strFolder, bool bAtFront=true);
|
54 |
|
|
static const CString LoadString (UINT id);
|
55 |
|
|
|
56 |
|
|
// Messagebox functions
|
57 |
|
|
|
58 |
|
|
// Vararg message box compositor
|
59 |
|
|
static int MessageBoxF (LPCTSTR pszFormat, ...);
|
60 |
|
|
// Same, with type
|
61 |
|
|
static int MessageBoxFT (UINT nType, LPCTSTR pszFormat, ...);
|
62 |
|
|
// As above but with resource
|
63 |
|
|
static int MessageBoxFR (UINT nID, UINT nType, LPCTSTR pszFormat, ...);
|
64 |
|
|
// Same, with type
|
65 |
|
|
static int MessageBoxFR (UINT nID, LPCTSTR pszFormat, ...);
|
66 |
|
|
// vararg form
|
67 |
|
|
static int vMessageBox(UINT nType, LPCTSTR pszFormat, va_list marker);
|
68 |
|
|
|
69 |
|
|
// String functions
|
70 |
|
|
|
71 |
|
|
// Chop the string into pieces using separator cSep.
|
72 |
|
|
// The Boolean controls whether " and \ make a difference
|
73 |
|
|
static int Chop(LPCTSTR psz,CStringArray &ar,TCHAR cSep=_TCHAR(' '),bool bObserveStrings=false,bool bBackslashQuotes=false);
|
74 |
|
|
static int Chop(LPCTSTR psz,CStringArray &ar,LPCTSTR pszSep, bool bObserveStrings=false,bool bBackslashQuotes=false);
|
75 |
|
|
// String -> Integer, observing the current hex/decimal setting
|
76 |
|
|
static BOOL StrToItemIntegerType(const CString &str,__int64 &d);
|
77 |
|
|
static BOOL StrToDouble (const CString &strValue, double &dValue);
|
78 |
|
|
// Integer -> String, observing the current hex/decimal setting
|
79 |
|
|
static const CString IntToStr(__int64 d,bool bHex=false);
|
80 |
|
|
static const CString DoubleToStr (double dValue);
|
81 |
|
|
static CString StripExtraWhitespace (const CString & strInput);
|
82 |
|
|
|
83 |
|
|
// Provide a failure explanation for what just went wrong
|
84 |
|
|
static const CString Explanation (CFileException &exc);
|
85 |
|
|
static void UnicodeToCStr(LPCTSTR str,char *&psz);
|
86 |
|
|
static std::string UnicodeToStdStr(LPCTSTR str);
|
87 |
|
|
static CFileName WPath(const std::string &str);
|
88 |
|
|
static bool CopyFile (LPCTSTR pszSource,LPCTSTR pszDest);
|
89 |
|
|
|
90 |
|
|
};
|
91 |
|
|
|
92 |
|
|
#endif
|