20 #ifndef __REXSCRIPT_INC__
21 #define __REXSCRIPT_INC__
28 #include <libbbb/libbbb.h>
29 #include <libbbb/rexscriptblock.h>
30 #include <libbbb/varmap.h>
31 #include <libbbb/rexscript-predefined-commands.h>
32 #include <libbbb/list2d.h>
41 #if (!defined Q_OS_MSDOS) && (!defined Q_OS_WIN32) && (!defined Q_OS_WINCE)
42 #define ASCII_EC_BLACK "\x1b[30m"
43 #define ASCII_EC_RED "\x1b[31m"
44 #define ASCII_EC_GREEN "\x1b[32m"
45 #define ASCII_EC_GREY "\x1b[30;1m"
46 #define ASCII_EC_CLEAR "\x1b[0m"
48 #define ASCII_EC_BLACK ""
49 #define ASCII_EC_RED ""
50 #define ASCII_EC_GREEN ""
51 #define ASCII_EC_GREY ""
52 #define ASCII_EC_CLEAR ""
88 LOG_COMMANDS = 0x00004,
110 QStringList sl_lines_;
126 # define REX_VARIABLE_MARKER_START "\\$\\{"
128 # define REX_VARIABLE_MARKER_END "\\}"
131 # define VARIABLE_MARKER_START "${"
133 # define VARIABLE_MARKER_END "}"
136 # define REX_VARIABLE_2_MARKER_START "\\$\\$\\{\\{"
138 # define REX_VARIABLE_2_MARKER_END "\\}\\}"
141 # define VARIABLE_2_MARKER_START "$${{"
143 # define VARIABLE_2_MARKER_END "}}"
160 # define VGLOB_CRTPATH "CRTPATH"
172 QStringList init_files_;
175 QVector<CallStackEntry> call_stack_;
181 QVector<CmdFile> files_;
197 QVector<CmdEntry> commands_;
203 bool b_last_was_command;
209 EndOfRunCallback eor_kb_;
233 const QStringList & init_files,
256 const QStringList & initFiles (
void )
const
257 {
return init_files_; }
260 QString crtFile (
void );
263 QString crtRawLine (
void );
269 QString rawLine (
int i_file,
int i_line );
273 call_stack_.last().line_ = i;
279 Q_ASSERT( call_stack_.isEmpty() == false );
280 return call_stack_.last();
284 bool isStackEmpty (
void )
const
285 {
return call_stack_.isEmpty(); }
288 bool stackSize (
void )
const
289 {
return call_stack_.count(); }
292 bool inBlock (
void )
293 {
return ( block_stack_.
isEmpty() == false ); }
296 int returnValue (
void )
const
300 bool isRunning (
void )
const
301 {
return ( t_id_ > 0 ); }
304 QString tempStoragePath (
void )
const;
307 QString getTempPath (
const QString & s );
310 bool isLogTypeOn (
int id_type )
const
311 {
return ( ( log_types_ & id_type ) == id_type ); }
320 Q_ASSERT( i < block_stack_.
count( ) );
328 void setEndQuit (
void )
330 void setEndCallBack ( EndOfRunCallback kb )
331 { eor_ = CallBack; eor_kb_ = kb; }
332 void setEndSignal (
void )
333 { eor_ = CallSignal; }
334 void setEndQuiet (
void )
335 { eor_ = CallNoOne; }
340 { commands_.prepend( cmd ); }
344 { commands_.append( cmd ); }
352 void setLogTypeOn (
int id_type )
353 { log_types_ = log_types_ | id_type; }
356 void setLogTypeOff (
int id_type )
357 { log_types_ = log_types_ & (~id_type); }
360 bool appendLineToBlock(
const QString & s );
363 void fileError (
const QString & s_text );
366 void blockError (
const QString & s_text,
int line = -1 );
369 void error (
const QString & s_text );
373 const QString & s_title,
374 const QString & s_text
379 const QString & s_text
383 void errorInRexScriptBlock (
void );
387 const QString & s_file,
389 const QString & s_line,
390 const QString & s_text
395 const QString & s_title,
396 const QString & s_text
401 const QString & s_text
407 const QString & s_text
413 const QString & s_text
417 void fileDecoration (
void );
420 void blockDecoration (
void );
426 bool endBlock (
void );
431 const QString & s_cmd,
432 const QString & s_val,
437 void helperLogChange (
443 virtual bool helperLogType (
444 const QString & s_val,
462 virtual QString interpret (
463 const QString & s_in,
483 virtual bool delVariable (
508 void endProcessing (
void );
517 void timerEvent ( QTimerEvent * event );
522 bool processFile (
const QString & s_file );
525 bool processStack (
void );
528 bool processLine (
const QString & s_line );
531 bool processBlock (
RexScriptBlock * blk,
const QString & s_line );
534 QString replaceVars (
const QString & s_line );
540 void initCommands (
void );
549 static bool commandNoop (
RexScript * rexs,
const CmdEntry & cmd );
550 static bool commandWhites (
RexScript * rexs,
const CmdEntry & cmd );
551 static bool commandComments (
RexScript * rexs,
const CmdEntry & cmd );
552 static bool commandInclude (
RexScript * rexs,
const CmdEntry & cmd );
553 static bool commandFrequency (
RexScript * rexs,
const CmdEntry & cmd );
554 static bool commandLog (
RexScript * rexs,
const CmdEntry & cmd );
555 static bool commandWait (
RexScript * rexs,
const CmdEntry & cmd );
556 static bool commandEcho (
RexScript * rexs,
const CmdEntry & cmd );
557 static bool commandBeginLog (
RexScript * rexs,
const CmdEntry & cmd );
558 static bool commandBeginEcho (
RexScript * rexs,
const CmdEntry & cmd );
559 static bool commandBeginTempFile(
RexScript * rexs,
const CmdEntry & cmd );
560 static bool commandBeginDir (
RexScript * rexs,
const CmdEntry & cmd );
561 static bool commandSet (
RexScript * rexs,
const CmdEntry & cmd );
562 static bool commandSetB (
RexScript * rexs,
const CmdEntry & cmd );
563 static bool commandSetIdx (
RexScript * rexs,
const CmdEntry & cmd );
564 static bool commandAppend (
RexScript * rexs,
const CmdEntry & cmd );
565 static bool commandSplit (
RexScript * rexs,
const CmdEntry & cmd );
566 static bool commandReadF (
RexScript * rexs,
const CmdEntry & cmd );
567 static bool commandWriteF (
RexScript * rexs,
const CmdEntry & cmd );
568 static bool commandAppendF (
RexScript * rexs,
const CmdEntry & cmd );
569 static bool commandCompute (
RexScript * rexs,
const CmdEntry & cmd );
570 static bool commandIf (
RexScript * rexs,
const CmdEntry & cmd );
571 static bool commandForEach (
RexScript * rexs,
const CmdEntry & cmd );
572 static bool commandFor (
RexScript * rexs,
const CmdEntry & cmd );
573 static bool commandWhile (
RexScript * rexs,
const CmdEntry & cmd );
574 static bool commandDel (
RexScript * rexs,
const CmdEntry & cmd );
575 static bool commandDelF (
RexScript * rexs,
const CmdEntry & cmd );
576 static bool commandCopyF (
RexScript * rexs,
const CmdEntry & cmd );
577 static bool commandMoveF (
RexScript * rexs,
const CmdEntry & cmd );
578 static bool commandGetEnv (
RexScript * rexs,
const CmdEntry & cmd );
579 static bool commandSetEnv (
RexScript * rexs,
const CmdEntry & cmd );
604 void endOfTheRun (
void );
618 static QString toUnixName (
const QString & s );
621 static QString toProperName (
const QString & s );
630 static QString unixToCamelCase (
const QString & s,
bool first_upper =
true );
653 #endif // __REXSCRIPT_INC__