00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifndef CRCPPEMITTER_H
00012 #define CRCPPEMITTER_H
00013
00014 #ifdef __GNUG__
00015 #pragma interface "CRCppEmitter.h"
00016 #endif
00017
00018 #include <wxGuiTest/Common.h>
00019
00020 #include <map>
00021 #include <set>
00022
00023 #include <wx/textfile.h>
00024
00025 namespace wxTst {
00026
00027
00031 class CRCppEmitter
00032 {
00033 public:
00039 static CRCppEmitter * GetInstance ();
00040
00041
00045 static void Destroy ();
00046
00047
00053 virtual void SetTabSize (unsigned int size);
00054
00055
00061 virtual unsigned int GetTabSize () const;
00062
00063
00069 virtual wxString GetTab () const;
00070
00071
00081 virtual void SetTestCaseFileContext (const wxString &filename, size_t lineNmb = -1);
00082
00083
00091 virtual wxString GetCaptureFilename () const;
00092
00093
00099 virtual void AddComment (wxString str);
00100
00101
00107 virtual void AddCode (wxString str);
00108
00109
00115 virtual void AddVerbatimStringWithLineBreaks (wxString str);
00116
00117
00130 virtual wxString AddContainerLookupCode (const wxString &containerName,
00131 const wxString &itemDesc = _T(""),
00132 const wxString &containerVarNameSuffix = _T(""));
00133
00134
00149 virtual wxString MakeVarName (const wxString &name,
00150 const wxString &suffix = _T(""));
00151
00152 protected:
00156 CRCppEmitter ();
00157
00158
00162 virtual ~CRCppEmitter ();
00163
00164
00177 virtual wxString BreakString (const wxString &str,
00178 const wxArrayString &breakStrs,
00179 unsigned int &idx,
00180 size_t minIdx = wxString::npos,
00181 bool isCode = false) const;
00182
00183
00195 virtual bool HasBrokenInString (const wxString &line) const;
00196
00197
00205 virtual bool IsContainerVarNameDuplicate (const wxString &str) const;
00206
00207
00214 virtual wxString MakeFirstCharLowerCase (const wxString &str) const;
00215
00216 private:
00217 static CRCppEmitter *ms_instance;
00218
00219 wxTextFile m_origFile, m_newFile;
00220 wxString m_tab;
00221 unsigned int m_maxChars;
00222
00223
00224
00225 typedef std::map< wxString, wxString > ContainerMap;
00226 ContainerMap m_contMap;
00227
00228 typedef std::set< wxString > StringSet;
00229 StringSet m_varNameSet;
00230
00231 private:
00232
00233 CRCppEmitter (const CRCppEmitter &rhs);
00234 CRCppEmitter & operator= (const CRCppEmitter &rhs);
00235 };
00236
00237 }
00238
00239 #endif // CRCPPEMITTER_H
00240