Rev | Line | |
---|
[289] | 1 | #include <jenga/include/common/CmdLine.h>
|
---|
| 2 |
|
---|
| 3 | using namespace Jenga::Common;
|
---|
| 4 |
|
---|
| 5 | CmdLines::CmdLines( const std::string &strCmdLine )
|
---|
| 6 | {
|
---|
| 7 | for( int i=0; i<(int)strCmdLine.size() ; i++ )
|
---|
| 8 | {
|
---|
| 9 | if( strCmdLine[i] == '/' )
|
---|
| 10 | {
|
---|
| 11 | i++;
|
---|
| 12 |
|
---|
| 13 | char temporary[255];
|
---|
| 14 |
|
---|
| 15 | // コマンド文字列(オプション名)を抽出
|
---|
| 16 | for( int j = 0; ; j++, i++ )
|
---|
| 17 | {
|
---|
| 18 | if( isalpha( strCmdLine[i] ) || isdigit( strCmdLine[i] ) || strCmdLine[i] == '_' )
|
---|
| 19 | {
|
---|
| 20 | temporary[j] = strCmdLine[i];
|
---|
| 21 | }
|
---|
| 22 | else
|
---|
| 23 | {
|
---|
| 24 | temporary[j] = 0;
|
---|
| 25 | break;
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 | while( strCmdLine[i] == ' ' ) i++;
|
---|
| 29 |
|
---|
| 30 | std::string command = temporary;
|
---|
| 31 | std::string parameter = "";
|
---|
| 32 |
|
---|
| 33 | if( (int)strCmdLine.size() > i && strCmdLine[i] != '/' )
|
---|
| 34 | {
|
---|
| 35 | // パラメータを抽出
|
---|
| 36 | if( strCmdLine[i] == '\"' )
|
---|
| 37 | {
|
---|
| 38 | i++;
|
---|
| 39 | //ダブルクォートの中身を取り出す
|
---|
| 40 | for( int j=0; ; j++, i++ )
|
---|
| 41 | {
|
---|
| 42 | if( strCmdLine[i] == '\"' || strCmdLine[i] == '\0' )
|
---|
| 43 | {
|
---|
| 44 | temporary[j] = 0;
|
---|
| 45 |
|
---|
| 46 | if( strCmdLine[i] == '\"' ) i++;
|
---|
| 47 | break;
|
---|
| 48 | }
|
---|
| 49 | temporary[j] = strCmdLine[i];
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 | else
|
---|
| 53 | {
|
---|
| 54 | //空白またはヌル文字以前を取り出す
|
---|
| 55 | for( int j=0; ; j++, i++ )
|
---|
| 56 | {
|
---|
| 57 | if( strCmdLine[i] == ' ' || strCmdLine[i] == '\0' )
|
---|
| 58 | {
|
---|
| 59 | temporary[j] = 0;
|
---|
| 60 | break;
|
---|
| 61 | }
|
---|
| 62 | temporary[j] = strCmdLine[i];
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 | parameter = temporary;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | this->push_back( CmdLine( command, parameter ) );
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.