/[pcsx2_0.9.7]/trunk/common/include/Utilities/StringHelpers.h
ViewVC logotype

Annotation of /trunk/common/include/Utilities/StringHelpers.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (hide annotations) (download)
Tue Sep 7 03:24:11 2010 UTC (9 years, 10 months ago) by william
File MIME type: text/plain
File size: 3785 byte(s)
committing r3113 initial commit again...
1 william 31 /* PCSX2 - PS2 Emulator for PCs
2     * Copyright (C) 2002-2010 PCSX2 Dev Team
3     *
4     * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5     * of the GNU Lesser General Public License as published by the Free Software Found-
6     * ation, either version 3 of the License, or (at your option) any later version.
7     *
8     * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10     * PURPOSE. See the GNU General Public License for more details.
11     *
12     * You should have received a copy of the GNU General Public License along with PCSX2.
13     * If not, see <http://www.gnu.org/licenses/>.
14     */
15    
16     #pragma once
17    
18     #include "Dependencies.h"
19    
20     #include <wx/tokenzr.h>
21     #include <wx/gdicmn.h> // for wxPoint/wxRect stuff
22    
23     extern void px_fputs( FILE* fp, const char* src );
24    
25     extern wxString fromUTF8( const char* src );
26     extern wxString fromAscii( const char* src );
27    
28     // wxWidgets lacks one of its own...
29     extern const wxRect wxDefaultRect;
30    
31     extern void SplitString( wxArrayString& dest, const wxString& src, const wxString& delims, wxStringTokenizerMode mode = wxTOKEN_RET_EMPTY_ALL );
32     extern void JoinString( wxString& dest, const wxArrayString& src, const wxString& separator );
33    
34     extern wxString ToString( const wxPoint& src, const wxString& separator=L"," );
35     extern wxString ToString( const wxSize& src, const wxString& separator=L"," );
36     extern wxString ToString( const wxRect& src, const wxString& separator=L"," );
37    
38     extern bool TryParse( wxPoint& dest, const wxStringTokenizer& parts );
39     extern bool TryParse( wxSize& dest, const wxStringTokenizer& parts );
40    
41     extern bool TryParse( wxPoint& dest, const wxString& src, const wxPoint& defval=wxDefaultPosition, const wxString& separators=L",");
42     extern bool TryParse( wxSize& dest, const wxString& src, const wxSize& defval=wxDefaultSize, const wxString& separators=L",");
43     extern bool TryParse( wxRect& dest, const wxString& src, const wxRect& defval=wxDefaultRect, const wxString& separators=L",");
44    
45     // --------------------------------------------------------------------------------------
46     // ParsedAssignmentString
47     // --------------------------------------------------------------------------------------
48     // This class is a simple helper for parsing INI-style assignments, in the typical form of:
49     // variable = value
50     // filename = SomeString.txt
51     // integer = 15
52     //
53     // This parser supports both '//' and ';' at the head of a line as indicators of a commented
54     // line, and such a line will return empty strings for l- and r-value.
55     //
56     // No type handling is performed -- the user must manually parse strings into integers, etc.
57     // For advanced "fully functional" ini file parsing, consider using wxFileConfig instead.
58     //
59     struct ParsedAssignmentString
60     {
61     wxString lvalue;
62     wxString rvalue;
63     bool IsComment;
64    
65     ParsedAssignmentString( const wxString& src );
66     };
67    
68     extern wxString FastFormatString_Ascii(const char* fmt, va_list argptr);
69     extern wxString FastFormatString_Unicode(const wxChar* fmt, va_list argptr);
70    
71    
72     //////////////////////////////////////////////////////////////////////////////////////////
73     // Custom internal sprintf functions, which are ASCII only (even in UNICODE builds)
74     //
75     // These functions are useful since they are ASCII always, even under Unicode. Typically
76     // even in a unicode app.
77    
78     extern void ssprintf(std::string& dest, const char* fmt, ...);
79     extern void ssappendf(std::string& dest, const char* format, ...);
80     extern void vssprintf(std::string& dest, const char* format, va_list args);
81     extern void vssappendf(std::string& dest, const char* format, va_list args);
82    
83     extern std::string fmt_string( const char* fmt, ... );
84     extern std::string vfmt_string( const char* fmt, va_list args );

  ViewVC Help
Powered by ViewVC 1.1.22