ByteString->rtl::OString

This commit is contained in:
Caolán McNamara
2011-12-19 22:39:38 +00:00
parent 865aba9fa7
commit b0604113bc

View File

@@ -48,17 +48,17 @@
#define STATE_OUTPUTY 0xff #define STATE_OUTPUTY 0xff
// set of global variables // set of global variables
ByteString sInputFile; rtl::OString sInputFile;
sal_Bool bEnableExport; sal_Bool bEnableExport;
sal_Bool bMergeMode; sal_Bool bMergeMode;
sal_Bool bErrorLog; sal_Bool bErrorLog;
sal_Bool bUTF8; sal_Bool bUTF8;
ByteString sPrj; rtl::OString sPrj;
ByteString sPrjRoot; rtl::OString sPrjRoot;
ByteString sOutputFile; rtl::OString sOutputFile;
ByteString sOutputFileX; rtl::OString sOutputFileX;
ByteString sOutputFileY; rtl::OString sOutputFileY;
ByteString sSDFFile; rtl::OString sSDFFile;
/*****************************************************************************/ /*****************************************************************************/
sal_Bool ParseCommandLine( int argc, char* argv[]) sal_Bool ParseCommandLine( int argc, char* argv[])
@@ -77,41 +77,36 @@ sal_Bool ParseCommandLine( int argc, char* argv[])
sal_Bool bInput = sal_False; sal_Bool bInput = sal_False;
// parse command line // parse command line
for( int i = 1; i < argc; i++ ) { for( int i = 1; i < argc; i++ )
if ( ByteString( argv[ i ]).ToUpperAscii() == "-I" ) { {
rtl::OString aArg(rtl::OString(argv[i]).toAsciiUpperCase());
if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-I")))
nState = STATE_INPUT; // next tokens specifies source files nState = STATE_INPUT; // next tokens specifies source files
} else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-O")))
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-O" ) {
nState = STATE_OUTPUT; // next token specifies the dest file nState = STATE_OUTPUT; // next token specifies the dest file
} else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-X")))
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-X" ) {
nState = STATE_OUTPUTX; // next token specifies the dest file nState = STATE_OUTPUTX; // next token specifies the dest file
} else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-Y" )))
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-Y" ) {
nState = STATE_OUTPUTY; // next token specifies the dest file nState = STATE_OUTPUTY; // next token specifies the dest file
} else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-P" )))
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-P" ) {
nState = STATE_PRJ; // next token specifies the cur. project nState = STATE_PRJ; // next token specifies the cur. project
} else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-LF")))
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-LF" ) {
nState = STATE_FORCE_LANGUAGES; nState = STATE_FORCE_LANGUAGES;
} else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-R" )))
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-R" ) {
nState = STATE_ROOT; // next token specifies path to project root nState = STATE_ROOT; // next token specifies path to project root
} else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-M" )))
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-M" ) {
nState = STATE_SDFFILE; // next token specifies the merge database nState = STATE_SDFFILE; // next token specifies the merge database
} else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-E" )))
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-E" ) { {
nState = STATE_ERRORLOG; nState = STATE_ERRORLOG;
bErrorLog = sal_False; bErrorLog = sal_False;
} }
else if ( ByteString( argv[ i ]).ToUpperAscii() == "-L" ) { else if (aArg.equalsL(RTL_CONSTASCII_STRINGPARAM("-L" )))
nState = STATE_LANGUAGES; nState = STATE_LANGUAGES;
} else
else { {
switch ( nState ) { switch ( nState )
{
case STATE_NON: { case STATE_NON: {
return sal_False; // no valid command line return sal_False; // no valid command line
} }
@@ -200,57 +195,53 @@ int _cdecl main( int argc, char *argv[] )
} }
//sal_uInt32 startfull = Export::startMessure(); //sal_uInt32 startfull = Export::startMessure();
bool hasInputList = sInputFile.GetBuffer()[0]=='@'; bool hasInputList = sInputFile[0]=='@';
// printf("x = %s , y = %s , o = %s\n", sOutputFileX.GetBuffer(), sOutputFileY.GetBuffer() , sOutputFile.GetBuffer() );
bool hasNoError = true; bool hasNoError = true;
if ( sOutputFile.Len() ){ // Merge single file ? if ( sOutputFile.getLength() ){ // Merge single file ?
//printf("DBG: Inputfile = %s\n",sInputFile.GetBuffer());
HelpParser aParser( sInputFile, bUTF8 , false ); HelpParser aParser( sInputFile, bUTF8 , false );
if ( bMergeMode ) if ( bMergeMode )
{ {
//sal_uInt64 startreadloc = Export::startMessure(); //sal_uInt64 startreadloc = Export::startMessure();
MergeDataFile aMergeDataFile(sSDFFile, sInputFile, sal_False); MergeDataFile aMergeDataFile(sSDFFile, sInputFile, sal_False);
//Export::stopMessure( ByteString("read localize.sdf") , startreadloc );
hasNoError = aParser.Merge( sSDFFile, sOutputFile , Export::sLanguages , aMergeDataFile ); hasNoError = aParser.Merge( sSDFFile, sOutputFile , Export::sLanguages , aMergeDataFile );
} }
else else
hasNoError = aParser.CreateSDF( sOutputFile, sPrj, sPrjRoot, sInputFile, new XMLFile( '0' ), "help" ); hasNoError = aParser.CreateSDF( sOutputFile, sPrj, sPrjRoot, sInputFile, new XMLFile( '0' ), "help" );
}else if ( sOutputFileX.Len() && sOutputFileY.Len() && hasInputList ) { // Merge multiple files ? }else if ( sOutputFileX.getLength() && sOutputFileY.getLength() && hasInputList ) { // Merge multiple files ?
if ( bMergeMode ){ if ( bMergeMode ){
ifstream aFStream( sInputFile.Copy( 1 , sInputFile.Len() ).GetBuffer() , ios::in ); ifstream aFStream( sInputFile.copy( 1 , sInputFile.getLength() ).getStr() , ios::in );
if( !aFStream ){ if( !aFStream ){
cerr << "ERROR: - helpex - Can't open the file " << sInputFile.Copy( 1 , sInputFile.Len() ).GetBuffer() << "\n"; cerr << "ERROR: - helpex - Can't open the file " << sInputFile.copy( 1 , sInputFile.getLength() ).getStr() << "\n";
exit(-1); exit(-1);
} }
vector<ByteString> filelist; vector<rtl::OString> filelist;
rtl::OStringBuffer filename; rtl::OStringBuffer filename;
sal_Char aChar; sal_Char aChar;
while( aFStream.get( aChar ) ) while( aFStream.get( aChar ) )
{ {
if( aChar == ' ' || aChar == '\n') if( aChar == ' ' || aChar == '\n')
filelist.push_back( ByteString( filename.makeStringAndClear().getStr() ) ); filelist.push_back(filename.makeStringAndClear());
else else
filename.append( aChar ); filename.append( aChar );
} }
if( filename.getLength() > 0 ) if( filename.getLength() > 0 )
filelist.push_back( ByteString ( filename.makeStringAndClear().getStr() ) ); filelist.push_back(filename.makeStringAndClear());
aFStream.close(); aFStream.close();
ByteString sHelpFile(""); // dummy rtl::OString sHelpFile; // dummy
MergeDataFile aMergeDataFile( sSDFFile, sHelpFile, sal_False ); MergeDataFile aMergeDataFile( sSDFFile, sHelpFile, sal_False );
//aMergeDataFile.Dump();
std::vector<ByteString> aLanguages; std::vector<ByteString> aLanguages;
HelpParser::parse_languages( aLanguages , aMergeDataFile ); HelpParser::parse_languages( aLanguages , aMergeDataFile );
bool bCreateDir = true; bool bCreateDir = true;
for( vector<ByteString>::iterator pos = filelist.begin() ; pos != filelist.end() ; ++pos ) for( vector<rtl::OString>::iterator pos = filelist.begin() ; pos != filelist.end() ; ++pos )
{ {
sHelpFile = *pos; sHelpFile = *pos;
cout << ".";cout.flush(); cout << ".";cout.flush();
@@ -263,7 +254,6 @@ int _cdecl main( int argc, char *argv[] )
} else } else
cerr << "helpex ERROR: Wrong input parameters!\n"; cerr << "helpex ERROR: Wrong input parameters!\n";
//Export::stopMessure( ByteString("full cycle") , startfull );
if( hasNoError ) if( hasNoError )
return 0; return 0;
else else