- Timestamp:
- 08/15/11 14:23:52 (13 years ago)
- Location:
- trunk/MFCtooling/replay
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MFCtooling/replay/replay.cpp
r160 r161 8 8 #include <iostream> 9 9 10 #include "options.h" 11 12 const char * optv[] = { 13 "r:resultfile <string>", 14 "d:msgdelay <number>", 15 "w:wait <number>", 16 "s:startdelay <number>", 17 "p:path <string>" 18 }; 19 20 void convertTCharToChar(const TCHAR * source, char ** dest) { 21 #ifdef UNICODE 22 std::wstring wstr(source); 23 int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); 24 std::string strTo( size_needed, 0 ); 25 WideCharToMultiByte (CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); 26 *dest = new char[strTo.size()+1]; 27 memcpy((void*)*dest, strTo.c_str(), strTo.size()+1); 28 #else 29 std::string str(source); 30 *dest = new char[strTo.size()+1]; 31 memcpy(*dest, strTo.c_str(), strTo.size()+1); 32 #endif 33 } 34 35 void convertCharToTChar(const char * source, TCHAR ** dest) { 36 #ifdef UNICODE 37 std::string str(source); 38 int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0); 39 std::wstring wstrTo( size_needed, 0 ); 40 MultiByteToWideChar (CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed); 41 *dest = new TCHAR[wstrTo.size()+1]; 42 memcpy((void*)*dest, wstrTo.c_str(), (wstrTo.size()+1)*sizeof(TCHAR)); 43 #else 44 std::string str(source); 45 *dest = new char[strTo.size()+1]; 46 memcpy(*dest, strTo.c_str(), strTo.size()+1); 47 #endif 48 } 49 10 50 int _tmain(int argc, _TCHAR* argv[]) 11 51 { 52 int optchar; 53 const char * optarg; 54 55 // set default values 56 TCHAR * resultfile = NULL; 57 int msgdelay = 0; 58 int startdelay = 5000; 59 int wait = 1; 60 TCHAR * workingPath = NULL; 61 62 int argc_char = argc-2; 63 char ** argv_char = new char*[argc_char]; 64 65 // convert argv to char*[] 66 convertTCharToChar(argv[0], &argv_char[0]); 67 for( int i=3; i<argc; i++ ) { 68 convertTCharToChar(argv[i], &argv_char[i-2]); 69 } 70 71 // parse options 72 Options opts(*argv_char, optv); 73 OptArgvIter iter(--argc_char, ++argv_char); 74 while( optchar = opts(iter, optarg) ) { 75 switch(optchar) { 76 case 'r': 77 convertCharToTChar(optarg, &resultfile); 78 break; 79 case 'd': 80 msgdelay = atoi(optarg); 81 break; 82 case 'w': 83 wait = atoi(optarg); 84 break; 85 case 'p': 86 convertCharToTChar(optarg, &workingPath); 87 break; 88 case 's': 89 startdelay = atoi(optarg); 90 break; 91 default: 92 break; 93 } 94 } 95 for( int i=0; i<argc_char; i++ ) { 96 delete[] argv_char[i]; 97 } 98 //delete[] argv_char; //TODO does not work?! 99 12 100 if (argc<4) 13 101 { 14 std::wcout << "Usage: " << argv[0] << "<replayfile> <applicationundertest> [<resultfile>] [<useDefaultDelay>] [<waitAfterFinish>]" << std::endl;102 std::wcout << L"Usage: " << argv[0] << L"<replayfile> <applicationundertest> [-r <resultfile>] [-d <useDefaultDelay>] [-w <waitAfterFinish>] [-p <workingPath>] [-s <startupDelay>]" << std::endl; 15 103 return 0; 16 104 } 17 105 TCHAR * replayfile = argv[1]; 18 106 TCHAR * appUnderTest = argv[2]; 19 TCHAR * resultfile = NULL;20 bool useDefaultDelay = true;21 int wait = 1;22 if( argc>=4 ) {23 TCHAR * resultfile = argv[3];24 }25 if( argc>=5 ) {26 useDefaultDelay = (bool) _tstoi(argv[4]);27 }28 if( argc>=6 ) {29 wait = _tstoi(argv[5]);30 }31 107 32 108 // initialize COM library for the current thread … … 45 121 TestResults results(replayfile); 46 122 std::wcout << L"replaying sessions in " << argv[1] << std::endl; 47 LogParser * parser = new LogParser(appUnderTest, 5000, &results, useDefaultDelay);123 LogParser * parser = new LogParser(appUnderTest, startdelay, &results, (bool) msgdelay); 48 124 pXMLReader->putContentHandler(parser); 49 125 hr = pXMLReader->parseURL(replayfile); … … 64 140 } 65 141 142 delete resultfile; 143 66 144 return 0; 67 145 } -
trunk/MFCtooling/replay/replay.vcproj
r105 r161 162 162 <Tool 163 163 Name="VCPostBuildEventTool" 164 CommandLine="copy C:\Projects\MFCtooling\Release\replay.exe C:\replay\tools\replay.exe /y" 164 165 /> 165 166 </Configuration> … … 175 176 <File 176 177 RelativePath=".\LogParser.cpp" 178 > 179 </File> 180 <File 181 RelativePath=".\options.cpp" 177 182 > 178 183 </File> … … 224 229 </File> 225 230 <File 231 RelativePath=".\options.h" 232 > 233 </File> 234 <File 226 235 RelativePath=".\SAXContentHandlerImpl.h" 227 236 >
Note: See TracChangeset
for help on using the changeset viewer.