1051 lines
54 KiB
HTML
1051 lines
54 KiB
HTML
<HTML>
|
||
<HEAD>
|
||
<TITLE>R_STRCOPY</TITLE>
|
||
<META NAME="Generator" CONTENT="KDOC ">
|
||
</HEAD>
|
||
<BODY bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#000099" alink= "#ffffff">
|
||
|
||
<table BORDER=0 COLS=1 WIDTH="100%" BGCOLOR="#FFFFCC" NOSAVE >
|
||
<tr ALIGN=CENTER VALIGN=CENTER NOSAVE>
|
||
<td NOSAVE><font face="Arial,Helvetica"><font size=+2></font></font>
|
||
<br><font face="Arial,Helvetica"><font size=+2>CCS Modul <b>R_STRCOPY</b></font></font>
|
||
<br> </td>
|
||
</tr>
|
||
</table>
|
||
<PRE>
|
||
Funktionsbeschreibung:
|
||
|
||
Mit diesem Modul kann der Anwender Substrings (Zeichenketten)
|
||
aus einem uebergebenen String oder aus einer Datei extrahieren
|
||
und via '&'-Variable weitergeben.
|
||
|
||
Beschreibung der Modulparameter:</pre><b><a name="param1">1</a> PRUEFSCHRITT</b><pre>
|
||
GAUDI Pruefschritt
|
||
------------------------------</pre><b><a name="param2">2</a> POSITION</b><pre>
|
||
PAV- Position
|
||
------------------------------</pre><b><a name="param3">3</a> MODE</b><pre>
|
||
INIT
|
||
Der erstmalige Aufruf von R_STRCOPY in einer Pruefliste
|
||
muss einer mit INIT sein (sonstige Parameter werden ignoriert).
|
||
MAKE / ~_UC / ~_LC
|
||
Es wird ein Zugriff auf eine bereits gespeicherte Datei
|
||
ausgefuehrt und die entsprechenden Eintraege an die
|
||
Schnittstelle uebergeben.
|
||
Der Parameter INPUTFILE muss mit einem gueltigen Dateipfad
|
||
versehen sein.
|
||
Mit dem Parameter EXECUTION wird gesteuert, wann der Datei-
|
||
zugriff stattfinden soll.
|
||
READFILE / ~_UC / ~_LC
|
||
eine Datei wird komplett einmalig gelesen und intern
|
||
gespeichert, so dass nachfolgende Verwendungen
|
||
ein erneutes Oeffnen nicht erforderlich machen;
|
||
EXTRACT / ~_UC / ~_LC
|
||
eine Datei wird ausschliesslich zum Lesen geoeffnet,
|
||
um den gewuenschten Substring zu extrahieren und
|
||
intern zu speichern;
|
||
die Datei selbst wird nicht gespeichert, dh. bei
|
||
einem erneuten Aufruf mit demselben Dateinamen wird
|
||
die Datei wiederum geoeffnet und ein weiterer
|
||
Substring daraus extrahiert;
|
||
wurde das Modul bereits mit dem Modus READ aufgerufen,
|
||
ist die betreffende Datei bereits geladen, ein
|
||
erneuter Dateizugriff entfaellt in diesem Fall;
|
||
|
||
Durch das Suffix '_LC' (lowercase) bzw. '_UC' (uppercase)
|
||
kann bestimmt werden, dass der angegebene Dateiname (inkl.Pfad)
|
||
entweder komplett in Klein- oder Grossbuchstaben zu wandeln ist.
|
||
Fehlt ein Suffix, wird davon ausgegangen, dass der Dateiname
|
||
so zu uebernehmen ist, wie er von der GAUDI-Schnittstelle
|
||
angeboten wird.
|
||
|
||
Der Default-Eintrag ist '-' (Minus) mit derselben Bedeutung
|
||
wie INIT.
|
||
|
||
------------------------------</pre><b><a name="param4">4</a> EXECUTION</b><pre>
|
||
vom Anwender kann hiermit gesteuert werden, wann das Modul
|
||
aktiv werden soll;
|
||
LOAD - das Modul erzeugt bereits im Ruestlauf aus den
|
||
Eingaben die gewuenschte Ausgabe, dh. es wird
|
||
im Ruestlauf bereits eine Datei geoeffnet, um
|
||
daraus z.B. den gewuenschten Teilstring zu
|
||
extrahieren;
|
||
in den nachfolgenden Prueflistendurchlaeufen
|
||
findet ein Oeffnen einer Datei nicht mehr statt;
|
||
FIRST - die gleichen Aktivitaeten wie bei LOAD, mit dem
|
||
Unterschied, dass das Modul im Ruestlauf keine
|
||
Aktivitaet zeigt;
|
||
auch hier werden Dateien nur einmalig, und zwar
|
||
im ersten Listenlauf, geoeffnet;
|
||
TEST - das Modul ist im Ruestlauf inaktiv; alle Aktvitaeten
|
||
finden erst ab dem ersten Prueflistenlauf nach
|
||
einem Ruestlauf statt;
|
||
Dateien werden mit jedem neuen Listenlauf erneut
|
||
geoeffnet, um daraus zu lesen;
|
||
|
||
Der Default-Eintrag ist '-' (Minus) mit derselben Bedeutung
|
||
wie LOAD.
|
||
|
||
------------------------------</pre><b><a name="param5">5</a> INPUTSTRING</b><pre>
|
||
die Zeichenkette, aus der ein Substring extrahiert werden soll;
|
||
dies kann auch eine '&'-Variable sein;
|
||
die maximale Laenge einer Zeichenkette betraegt 80 Zeichen
|
||
(entspricht 80 Bytes);
|
||
|
||
------------------------------</pre><b><a name="param6">6</a> INPUTFILE</b><pre>
|
||
ein Dateiname (inkl. Pfad), aus dem ein Substring extrahiert
|
||
werden soll;
|
||
Dateinamen bestehen im Default-Fall aus Grossbuchstaben (die
|
||
GAUDI-Schnittstelle liefert solche), durch ein optionales
|
||
Suffix hinter der Modus-Angabe ('_LC') kann eine Wandlung in
|
||
Kleinbuchstaben initiiert werden;
|
||
|
||
Der Basispfad auf dem zugeordneten Leitrechner ist:
|
||
"Leitrechner:/daten/pruef_ccs/"
|
||
somit wird mit Eingabe von "dect/ptc/fe113401.01" folgende
|
||
Datei auf dem Leitrechner geoeffnet:
|
||
"Leitrechner:/daten/pruef_ccs/dect/ptc/fe113401.01"
|
||
|
||
------------------------------</pre><b><a name="param7">7</a> LINE_IN_FILE</b><pre>
|
||
Auswahl einer Zeile in einer Datei (gezaehlt wird von 1 an);
|
||
folgende Steuerzeichen in einer Datei werden als Zeilenende-
|
||
Kennung interpretiert:
|
||
CR (= CarriageReturn)
|
||
LF (= Linefeed)
|
||
CRLF (= CarriageReturn Linefeed)
|
||
|
||
------------------------------</pre><b><a name="param8">8</a> STARTINDEX</b><pre>
|
||
das erste Byte (des uebergebenen Strings, der Datei oder
|
||
der Zeile einer Datei) das extrahiert werden soll;
|
||
gezaehlt wird von 1 an;
|
||
|
||
wird beim Parameter LINE_IN_FILE der Default-Eintrag ('-')
|
||
belassen, kann auch ueber Zeilenenden hinweg ein Substring
|
||
(inkl. einer Zeilenende-Kennung) extrahiert werden;
|
||
|
||
------------------------------</pre><b><a name="param9">9</a> STOPINDEX</b><pre>
|
||
das letzte Byte (des uebergebenen Strings, der Datei oder
|
||
der Zeile einer Datei), das extrahiert werden soll (siehe oben);
|
||
|
||
ist der START~ groesser als der STOPINDEX, wird der Substring
|
||
invertiert in OUTPUTSTRING ausgegeben;
|
||
|
||
------------------------------</pre><b><a name="param10">10</a> FIELDNUMBER</b><pre>
|
||
alternativ zu START~ und STOPINDEX kann ein durch einen
|
||
Separator begrenztes Feld (des uebergebenen Strings, der Datei
|
||
oder der Zeile einer Datei) extrahiert werden
|
||
(gezaehlt wird von 1 an);
|
||
|
||
das erste Feld beginnt nicht zwingend ab einem
|
||
Begrenzungszeichen, das letzte Feld beginnt nach dem
|
||
angegebenen Begrenzungszeichen und endet vor einer evtl.
|
||
vorhandenen Zeilenende-Kennung oder dem Dateiende;
|
||
|
||
------------------------------</pre><b><a name="param11">11</a> SEPARATOR</b><pre>
|
||
ein oder mehrere ASCII-Zeichen, mit dem/denen die Zeichen
|
||
eines Strings (in einer Datei) voneinander getrennt sind;
|
||
das/die Zeichen werden zwischen Anfuehrungszeichen gesetzt;
|
||
|
||
Beispiel: ", ,"
|
||
der Separator besteht aus 3 Zeichen einem Komma,
|
||
einem Leerzeichen und einem weiteren Komma;
|
||
|
||
------------------------------</pre><b><a name="param12">12</a> OUTPUTSTRING</b><pre>
|
||
der gewuenschte Substring in einer '&'-Variablen
|
||
|
||
------------------------------</pre><b><a name="param13">13</a> ERRORFLAG</b><pre>
|
||
enthaelt im Fehlerfall eine 1;
|
||
z.B. das Modul M_AUSWERTUNG kann diesen Parameter auswerten;
|
||
|
||
Input:
|
||
|
||
Output:
|
||
none
|
||
|
||
----------------------------------------------------------
|
||
Return Value:
|
||
= 0: Successful completion
|
||
|
||
----------------------------------------------------------
|
||
Beispiel (optional):
|
||
|
||
----------------------------------------------------------
|
||
<\userdoc>
|
||
C4
|
||
int r_strcopy( shm_stringpointer *zeilen_wert
|
||
,long index_on_expPrfLst
|
||
,long anzPrmtr )
|
||
{
|
||
|
||
r_strcopy
|
||
|
||
statische Speicher
|
||
static QMap<QString, QString> s_TStepMap; // Pruefschritt <--> Resultstring
|
||
static QMap<QString, QString> s_FileMap; // Filename <--> Filecontent
|
||
|
||
|
||
Lokale Variable
|
||
QString resultstring;
|
||
|
||
int ret_val = 0;
|
||
|
||
|
||
Schrittbetriebs-Handling
|
||
int schritt_aktiv = schrittbetrieb( zeilen_wert, index_on_expPrfLst );
|
||
|
||
if ( schritt_aktiv != 1 ) {
|
||
return 0;
|
||
|
||
}
|
||
|
||
GAUDI-Parameter ausgeben:
|
||
QString pruefschritt = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + PRUEFSCHRITT];
|
||
QString position = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + POSITION];
|
||
QString action = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + ACTION];
|
||
QString execution = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + EXECUTION];
|
||
QString inputfile = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + INPUTFILE];
|
||
QString ignore = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + IGNORE];
|
||
QString line_in_file = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + LINE_IN_FILE];
|
||
QString startindex = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + STARTINDEX];
|
||
QString stopindex = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + STOPINDEX];
|
||
QString fieldnumber = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + FIELDNUMBER];
|
||
QString separator = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + SEPARATOR];
|
||
|
||
QString inputstring;
|
||
|
||
#ifdef VARIABLENVERWALTUNG_MEMSTR
|
||
Variablenverwaltung *verwa_ptr1; // Zugriff auf Variablenverwaltung
|
||
|
||
verwa_ptr1 = (Variablenverwaltung*) zeilen_wert->ptr[index_on_expPrfLst + INPUTSTRING];
|
||
verwa_ptr1->get_wert(inputstring);
|
||
#else
|
||
inputstring = (const char *)*zeilen_wert->ptr[index_on_expPrfLst + INPUTSTRING];
|
||
#endif
|
||
|
||
debug_message( __FILE__, __LINE__, DEB_GAUDI
|
||
,"Input fuer Modul \"R_STRCOPY\":\n"
|
||
"PRUEFSCHRITT = [%s]\n"
|
||
"POSITION = [%s]\n"
|
||
"ACTION = [%s]\n"
|
||
"EXECUTION = [%s]\n"
|
||
"INPUTSTRING = [%s]\n"
|
||
"INPUTFILE = [%s]\n"
|
||
"IGNORE = [%s]\n"
|
||
"LINE_IN_FILE = [%s]\n"
|
||
"STARTINDEX = [%s]\n"
|
||
"STOPINDEX = [%s]\n"
|
||
"FIELD = [%s]\n"
|
||
"SEPARATOR = [%s]"
|
||
,(const char *)pruefschritt, (const char *)position, (const char *)action
|
||
,(const char *)execution, (const char *)inputstring, (const char *)inputfile
|
||
,(const char *)ignore
|
||
,(const char *)line_in_file, (const char *)startindex, (const char *)stopindex
|
||
,(const char *)fieldnumber, (const char *)separator );
|
||
|
||
if ( strstr(Ssp_vi->job.liststate,NORMAL) ) {
|
||
|
||
NORMAL
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> Liststate ====> NORMAL" );
|
||
|
||
if ( action == ACTION_INIT || action == "-" ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_INIT" );
|
||
|
||
r_strcopy_purge_map( s_TStepMap );
|
||
|
||
}
|
||
else if ( action.find(ACTION_READFILE) >= 0 ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_READFILE" );
|
||
|
||
if ( execution == EXE_LOAD ) {
|
||
if ( !inputfile.isEmpty() && inputfile != "-" ) {
|
||
|
||
Datei einlesen und bei Bedarf in Map speichern
|
||
if ( action.find("_LC") > 0 ) {
|
||
inputfile = inputfile.lower();
|
||
|
||
}
|
||
if ( r_strcopy_is_key_in_map(s_FileMap,inputfile) ) {
|
||
inputstring = s_FileMap[inputfile];
|
||
|
||
}
|
||
else {
|
||
r_strcopy_read_filecontent( inputfile, inputstring );
|
||
|
||
s_FileMap[inputfile] = inputstring;
|
||
|
||
}
|
||
}
|
||
}
|
||
else if ( execution == EXE_FIRST ) {
|
||
;
|
||
|
||
}
|
||
else if ( execution == EXE_TEST ) {
|
||
;
|
||
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter EXECUTION-Parameter [%s] - nicht LOAD, FIRST, TEST"
|
||
// ,(const char *)execution);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown EXECUTION-parameter [%s] - not LOAD, FIRST, TEST"
|
||
,(const char *)execution);
|
||
ret_val = -1;
|
||
|
||
}
|
||
}
|
||
else if ( action.find(ACTION_EXTRACT) >= 0 ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_EXTRACT" );
|
||
|
||
if ( execution == EXE_LOAD ) {
|
||
}
|
||
else if ( execution == EXE_FIRST ) {
|
||
;
|
||
|
||
}
|
||
else if ( execution == EXE_TEST ) {
|
||
;
|
||
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter EXECUTION-Parameter [%s] - nicht LOAD, FIRST, TEST"
|
||
// ,(const char *)execution);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown EXECUTION-parameter [%s] - not LOAD, FIRST, TEST"
|
||
,(const char *)execution);
|
||
ret_val = -1;
|
||
|
||
}
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter ACTION-Parameter [%s] - nicht INIT, READ, EXTRACT"
|
||
// ,(const char *)action);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown ACTION-parameter [%s] - not INIT, READ, EXTRACT"
|
||
,(const char *)action);
|
||
ret_val = -1;
|
||
|
||
}
|
||
if ( startindex != "-" && stopindex != "-" ) {
|
||
resultstring = r_strcopy_extract_string_by_index( inputstring, startindex, stopindex );
|
||
|
||
}
|
||
else {
|
||
resultstring = r_strcopy_extract_string_by_number( inputstring, fieldnumber, separator );
|
||
|
||
}
|
||
|
||
#ifdef VARIABLENVERWALTUNG_MEMSTR
|
||
verwa_ptr1 = (Variablenverwaltung*) zeilen_wert->ptr[index_on_expPrfLst + OUTPUTSTRING];
|
||
verwa_ptr1->put_wert(resultstring);
|
||
#else
|
||
*zeilen_wert->ptr[index_on_expPrfLst + OUTPUTSTRING] = (STRING)(char *)(const char *)resultstring;
|
||
#endif
|
||
}
|
||
else if ( strstr(Ssp_vi->job.liststate,FIRSTRUN) ) {
|
||
|
||
FIRSTRUN
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> Liststate ====> FIRSTRUN" );
|
||
|
||
if ( action == ACTION_INIT || action == "-" ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_INIT" );
|
||
|
||
r_strcopy_purge_map( s_TStepMap );
|
||
|
||
}
|
||
else if ( action.find(ACTION_READFILE) >= 0 ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_READFILE" );
|
||
|
||
if ( execution == EXE_LOAD ) {
|
||
if ( !inputfile.isEmpty() && inputfile != "-" ) {
|
||
|
||
Datei einlesen und bei Bedarf in Map speichern
|
||
if ( action.find("_LC") > 0 ) {
|
||
inputfile = inputfile.lower();
|
||
|
||
}
|
||
if ( r_strcopy_is_key_in_map(s_FileMap,inputfile) ) {
|
||
inputstring = s_FileMap[inputfile];
|
||
|
||
}
|
||
else {
|
||
r_strcopy_read_filecontent( inputfile, inputstring );
|
||
|
||
s_FileMap[inputfile] = inputstring;
|
||
|
||
}
|
||
}
|
||
}
|
||
else if ( execution == EXE_FIRST ) {
|
||
;
|
||
|
||
}
|
||
else if ( execution == EXE_TEST ) {
|
||
;
|
||
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter EXECUTION-Parameter [%s] - nicht LOAD, FIRST, TEST"
|
||
// ,(const char *)execution);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown EXECUTION-parameter [%s] - not LOAD, FIRST, TEST"
|
||
,(const char *)execution);
|
||
ret_val = -1;
|
||
|
||
}
|
||
}
|
||
else if ( action.find(ACTION_EXTRACT) >= 0 ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_EXTRACT" );
|
||
|
||
if ( execution == EXE_LOAD ) {
|
||
}
|
||
else if ( execution == EXE_FIRST ) {
|
||
;
|
||
|
||
}
|
||
else if ( execution == EXE_TEST ) {
|
||
;
|
||
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter EXECUTION-Parameter [%s] - nicht LOAD, FIRST, TEST"
|
||
// ,(const char *)execution);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown EXECUTION-parameter [%s] - not LOAD, FIRST, TEST"
|
||
,(const char *)execution);
|
||
ret_val = -1;
|
||
|
||
}
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter ACTION-Parameter [%s] - nicht INIT, READ, EXTRACT"
|
||
// ,(const char *)action);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown ACTION-Parameter [%s] - not INIT, READ, EXTRACT"
|
||
,(const char *)action);
|
||
ret_val = -1;
|
||
|
||
}
|
||
if ( startindex != "-" && stopindex != "-" ) {
|
||
resultstring = r_strcopy_extract_string_by_index( inputstring, startindex, stopindex );
|
||
|
||
}
|
||
else {
|
||
resultstring = r_strcopy_extract_string_by_number( inputstring, fieldnumber, separator );
|
||
|
||
}
|
||
|
||
#ifdef VARIABLENVERWALTUNG_MEMSTR
|
||
verwa_ptr1 = (Variablenverwaltung*) zeilen_wert->ptr[index_on_expPrfLst + OUTPUTSTRING];
|
||
verwa_ptr1->put_wert(resultstring);
|
||
#else
|
||
*zeilen_wert->ptr[index_on_expPrfLst + OUTPUTSTRING] = (STRING)(char *)(const char *)resultstring;
|
||
#endif
|
||
}
|
||
else if ( strstr(Ssp_vi->job.liststate,PREINT) ) {
|
||
|
||
PREINT
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> Liststate ====> PREINT" );
|
||
|
||
if ( action == ACTION_INIT || action == "-" ) {
|
||
|
||
Mode: INIT
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_INIT" );
|
||
|
||
r_strcopy_purge_map( s_FileMap );
|
||
r_strcopy_purge_map( s_TStepMap );
|
||
|
||
}
|
||
else if ( action.find(ACTION_READFILE) >= 0 ) {
|
||
|
||
Mode: READ
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_READFILE" );
|
||
|
||
if ( execution == EXE_LOAD ) {
|
||
if ( !inputfile.isEmpty() && inputfile != "-" ) {
|
||
|
||
Datei einlesen und bei Bedarf in Map speichern
|
||
if ( action.find("_LC") > 0 ) {
|
||
inputfile = inputfile.lower();
|
||
|
||
}
|
||
if ( r_strcopy_is_key_in_map(s_FileMap,inputfile) ) {
|
||
inputstring = s_FileMap[inputfile];
|
||
|
||
}
|
||
else {
|
||
r_strcopy_read_filecontent( inputfile, inputstring );
|
||
|
||
s_FileMap[inputfile] = inputstring;
|
||
|
||
}
|
||
}
|
||
}
|
||
else if ( execution == EXE_FIRST || execution == EXE_TEST ) {
|
||
;
|
||
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter EXECUTION-Parameter [%s] - nicht LOAD, FIRST, TEST"
|
||
// ,(const char *)execution);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown EXECUTION-parameter [%s] - not LOAD, FIRST, TEST"
|
||
,(const char *)execution);
|
||
ret_val = -1;
|
||
|
||
}
|
||
}
|
||
else if ( action.find(ACTION_EXTRACT) >= 0 ) {
|
||
|
||
Mode: EXTRACT
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy> ACTION_EXTRACT" );
|
||
|
||
if ( execution == EXE_LOAD ) {
|
||
if ( !inputfile.isEmpty() && inputfile != "-" ) {
|
||
|
||
Substring aus Datei einlesen und in Map speichern
|
||
if ( action.find("_LC") > 0 ) {
|
||
inputfile = inputfile.lower();
|
||
|
||
}
|
||
}
|
||
else {
|
||
|
||
Substring aus Inputstring extrahieren
|
||
resultstring = inputstring;
|
||
|
||
}
|
||
}
|
||
else if ( execution == EXE_FIRST ) {
|
||
;
|
||
|
||
}
|
||
else if ( execution == EXE_TEST ) {
|
||
;
|
||
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter EXECUTION-Parameter [%s] - nicht LOAD, FIRST, TEST"
|
||
// ,(const char *)execution);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown EXECUTION-parameter [%s] - not LOAD, FIRST, TEST"
|
||
,(const char *)execution);
|
||
ret_val = -1;
|
||
|
||
}
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter ACTION-Parameter [%s] - nicht INIT, READ, EXTRACT"
|
||
// ,(const char *)action);
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown ACTION-parameter [%s] - not INIT, READ, EXTRACT"
|
||
,(const char *)action);
|
||
ret_val = -1;
|
||
|
||
}
|
||
if ( startindex != "-" && stopindex != "-" ) {
|
||
resultstring = r_strcopy_extract_string_by_index( inputstring, startindex, stopindex );
|
||
|
||
}
|
||
else {
|
||
resultstring = r_strcopy_extract_string_by_number( inputstring, fieldnumber, separator );
|
||
|
||
}
|
||
|
||
#ifdef VARIABLENVERWALTUNG_MEMSTR
|
||
verwa_ptr1 = (Variablenverwaltung*) zeilen_wert->ptr[index_on_expPrfLst + OUTPUTSTRING];
|
||
verwa_ptr1->put_wert(resultstring);
|
||
#else
|
||
*zeilen_wert->ptr[index_on_expPrfLst + OUTPUTSTRING] = (STRING)(char *)(const char *)resultstring;
|
||
#endif
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy> Unbekannter Listen-Zustand [%s] - nicht PREINT, FIRSTRUN, NORMAL"
|
||
// ,(const char *)Ssp_vi->job.liststate );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy> Unknown list state [%s] - not PREINT, FIRSTRUN, NORMAL"
|
||
,(const char *)Ssp_vi->job.liststate );
|
||
|
||
}
|
||
return 0;
|
||
|
||
}
|
||
|
||
r_strcopy_read_filecontent (6_testmodul_pool-testlisten_module-r_rechenmodule-r_strcopy)
|
||
SDOperation
|
||
|
||
History
|
||
-------
|
||
created by ohm3sa 07/21/1998 at 15:44
|
||
modified by klm3sa 01/14/2000 at 09:58
|
||
|
||
SD text
|
||
-------
|
||
C3
|
||
----------------------------------------------------------
|
||
Kurzbeschreibung: liest ein File bis zum Dateiende
|
||
|
||
----------------------------------------------------------
|
||
Schnittstelle:
|
||
#include <...h>
|
||
|
||
$Function$
|
||
|
||
----------------------------------------------------------
|
||
Funktionsbeschreibung:
|
||
|
||
Input:
|
||
|
||
Output:
|
||
none
|
||
|
||
----------------------------------------------------------
|
||
Return Value:
|
||
= 0: Successful completion
|
||
|
||
----------------------------------------------------------
|
||
Beispiel (optional):
|
||
|
||
----------------------------------------------------------
|
||
C4
|
||
int r_strcopy_read_filecontent( const QString &filename, QString &filecontent )
|
||
{
|
||
|
||
r_strcopy_read_filecontent
|
||
|
||
Lokale Variablen
|
||
int ret_val = 0;
|
||
|
||
|
||
vollstaendigen Pfadnamen bilden:
|
||
QString complete_filename;
|
||
|
||
char mainpath[256];
|
||
char NodeServer[80];
|
||
|
||
if ( get_dir( DIR_TLIST, 80, 80, mainpath, NodeServer ) ) {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy_read_filecontent> Datei [%s]\n"
|
||
// " kann wg. \"get_dir()\"-Fehler nicht geoeffnet werden", (const char *)filename );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy_read_filecontent> File [%s]\n"
|
||
" can not be opened due to \"get_dir()\" error", (const char *)filename );
|
||
ret_val = -1;
|
||
|
||
}
|
||
else {
|
||
complete_filename = mainpath;
|
||
complete_filename += filename;
|
||
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy_read_filecontent> lese Datei:\n [%s]"
|
||
,(const char *)complete_filename );
|
||
|
||
}
|
||
if ( 0 == ret_val ) {
|
||
|
||
Datei oeffnen
|
||
ifstream infile;
|
||
|
||
infile.open( complete_filename );
|
||
|
||
if ( !infile.rdbuf()->is_open() ) {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy_read_filecontent> Datei [%s] konnte nicht geoeffnet werden!"
|
||
// ,(const char *)complete_filename );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy_read_filecontent> File [%s] could not be opened!"
|
||
,(const char *)complete_filename );
|
||
ret_val = -1;
|
||
|
||
}
|
||
|
||
Datei Byte-weise einlesen:
|
||
if ( 0 == ret_val ) {
|
||
char ch;
|
||
|
||
filecontent.truncate(0);
|
||
|
||
while ( infile.get(ch) ) {
|
||
filecontent += ch;
|
||
|
||
}
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy_read_filecontent> Dateilaenge: [%d]"
|
||
,filecontent.length() );
|
||
|
||
if ( !infile.eof() ) {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy_read_filecontent> Fehler beim Lesen der Datei [%s]"
|
||
// ,(const char *)complete_filename );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy_read_filecontent> Error reading file [%s]"
|
||
,(const char *)complete_filename );
|
||
ret_val = -1;
|
||
|
||
}
|
||
}
|
||
|
||
Datei schliessen
|
||
infile.close();
|
||
|
||
}
|
||
return( ret_val );
|
||
|
||
}
|
||
|
||
r_strcopy_extract_string_by_index (6_testmodul_pool-testlisten_module-r_rechenmodule-r_strcopy)
|
||
SDOperation
|
||
|
||
History
|
||
-------
|
||
created by ohm3sa 07/14/1998 at 10:45
|
||
modified by klm3sa 01/14/2000 at 09:58
|
||
|
||
SD text
|
||
-------
|
||
C3
|
||
----------------------------------------------------------
|
||
Kurzbeschreibung: extrahiert einen Substring von Start bis Ende
|
||
|
||
----------------------------------------------------------
|
||
Schnittstelle:
|
||
#include <...h>
|
||
|
||
$Function$
|
||
|
||
----------------------------------------------------------
|
||
Funktionsbeschreibung:
|
||
|
||
Der zu extrahierende Substring darf eine Laenge von maximal
|
||
80 Zeichen nicht ueberschreiten!
|
||
|
||
Input:
|
||
|
||
Output:
|
||
none
|
||
|
||
----------------------------------------------------------
|
||
Return Value:
|
||
= 0: Successful completion
|
||
|
||
----------------------------------------------------------
|
||
Beispiel (optional):
|
||
|
||
----------------------------------------------------------
|
||
C4
|
||
QString r_strcopy_extract_string_by_index( const QString& input
|
||
,const QString& startstring, const QString& stopstring )
|
||
{
|
||
|
||
r_strcopy_extract_string_by_index
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy_extract_string_by_index> Start=[%s], Stop=[%s]"
|
||
,(const char *)startstring, (const char *)stopstring );
|
||
|
||
int start = atoi( (const char *)startstring );
|
||
int stop = atoi( (const char *)stopstring );
|
||
|
||
|
||
Rueckgabe-String initialisieren:
|
||
QString resultstring = "";
|
||
|
||
if ( start > 0 && start <= input.length() && stop > 0 && stop <= input.length() ) {
|
||
if ( start <= stop ) {
|
||
resultstring = input.mid( start-1, stop-start+1 );
|
||
}
|
||
else {
|
||
Substring in invertierter Reihenfolge generieren:
|
||
int index = start-1;
|
||
while ( index >= stop-1 ) {
|
||
resultstring += input.at(index--);
|
||
}
|
||
}
|
||
}
|
||
|
||
Im R<>stlauf Fehlermeldung unterdr<64>cken
|
||
else if ( strstr(Ssp_vi->job.liststate,PREINT) ) {
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy_extract_string_by_index> 'start' / 'stop' ausserhalb der String-Grenzen:\n"
|
||
// " Laenge = %d / start = %d / stop = %d", input.length(), start, stop );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy_extract_string_by_index> 'start' / 'stop' out of string bounds:\n"
|
||
" length = %d / start = %d / stop = %d", input.length(), start, stop );
|
||
|
||
}
|
||
debug_message( __FILE__, __LINE__, DEB_DATA, "r_strcopy_extract_string_by_index> Substring:\n"
|
||
" [%s]", (const char *)resultstring );
|
||
|
||
return resultstring;
|
||
|
||
}
|
||
|
||
r_strcopy_extract_string_by_number (6_testmodul_pool-testlisten_module-r_rechenmodule-r_strcopy)
|
||
SDOperation
|
||
|
||
History
|
||
-------
|
||
created by ohm3sa 07/14/1998 at 10:51
|
||
modified by klm3sa 01/14/2000 at 09:58
|
||
|
||
SD text
|
||
-------
|
||
C3
|
||
----------------------------------------------------------
|
||
Kurzbeschreibung: extrahiert ein durch Separatoren begrenztes
|
||
Feld
|
||
|
||
----------------------------------------------------------
|
||
Schnittstelle:
|
||
#include <...h>
|
||
|
||
$Function$
|
||
|
||
----------------------------------------------------------
|
||
Funktionsbeschreibung:
|
||
|
||
Input:
|
||
|
||
Output:
|
||
none
|
||
|
||
----------------------------------------------------------
|
||
Return Value:
|
||
= 0: Successful completion
|
||
|
||
----------------------------------------------------------
|
||
Beispiel (optional):
|
||
|
||
----------------------------------------------------------
|
||
C4
|
||
QString r_strcopy_extract_string_by_number( const QString& input
|
||
,const QString& fieldnumber, const QString& separator_with_delimiter )
|
||
{
|
||
|
||
r_strcopy_extract_string_by_number
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy_extract_string_by_number> Field=[%s], Separator=[%s]"
|
||
,(const char *)fieldnumber, (const char *)separator_with_delimiter );
|
||
|
||
int fieldno = atoi( (const char *)fieldnumber );
|
||
|
||
|
||
Rueckgabe-String initialisieren:
|
||
QString resultstring = "";
|
||
|
||
if ( fieldno > 0 ) {
|
||
unsigned seplength = separator_with_delimiter.length();
|
||
|
||
if ( (separator_with_delimiter.at(0) == '\"')
|
||
&& (separator_with_delimiter.at(seplength-1) == '\"') ) {
|
||
QString separator = separator_with_delimiter.mid( 1, (seplength-2) );
|
||
|
||
if ( separator.length() ) {
|
||
|
||
gesuchtes Feld (beginnend mit 1) aus den String-Daten extrahieren:
|
||
int hit_field = 0;
|
||
int index = 0;
|
||
|
||
do {
|
||
int next_index = input.find( separator, index );
|
||
|
||
if ( next_index < 0 ) {
|
||
|
||
Ende erreicht - abbrechen:
|
||
resultstring = input.mid( index );
|
||
hit_field++;
|
||
break;
|
||
|
||
}
|
||
resultstring = input.mid( index, (next_index-index) );
|
||
|
||
index = next_index + separator.length();
|
||
|
||
hit_field++;
|
||
|
||
} while ( hit_field < fieldno ) ;
|
||
|
||
gefunden ?
|
||
if ( hit_field != fieldno ) {
|
||
resultstring.truncate(0);
|
||
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy_extract_string_by_number> Field (%d) nicht besetzt / nicht existent"
|
||
// ,fieldno );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy_extract_string_by_number> Field (%d) not set / non-existent"
|
||
,fieldno );
|
||
|
||
}
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy_extract_string_by_number> Separator hat Laenge 0" );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy_extract_string_by_number> Separator has length 0" );
|
||
|
||
}
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy_extract_string_by_number> Separator nicht im Format \"...\":\n"
|
||
// ," [%s]"
|
||
// ,(const char *)separator_with_delimiter );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy_extract_string_by_number> Separator not in format \"...\":\n"
|
||
," [%s]"
|
||
,(const char *)separator_with_delimiter );
|
||
|
||
}
|
||
}
|
||
else {
|
||
// error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
// ,"r_strcopy_extract_string_by_number> 'fieldnumber' nicht groesser als 0" );
|
||
error_message( ERR_ERROR_TTNR, HEADER, __LINE__
|
||
,"r_strcopy_extract_string_by_number> 'fieldnumber' not greater than 0" );
|
||
|
||
}
|
||
debug_message( __FILE__, __LINE__, DEB_DATA, "r_strcopy_extract_string_by_number> Substring:\n"
|
||
" [%s]", (const char *)resultstring );
|
||
|
||
return resultstring;
|
||
|
||
}
|
||
|
||
r_strcopy_purge_map (6_testmodul_pool-testlisten_module-r_rechenmodule-r_strcopy)
|
||
SDOperation
|
||
|
||
History
|
||
-------
|
||
created by ohm3sa 07/21/1998 at 11:05
|
||
modified by klm3sa 01/14/2000 at 09:58
|
||
|
||
SD text
|
||
-------
|
||
C3
|
||
----------------------------------------------------------
|
||
Kurzbeschreibung: eine Map entleeren
|
||
----------------------------------------------------------
|
||
Schnittstelle:
|
||
#include <...h>
|
||
|
||
$Function$
|
||
|
||
----------------------------------------------------------
|
||
Funktionsbeschreibung:
|
||
|
||
Input:
|
||
|
||
Output:
|
||
none
|
||
|
||
----------------------------------------------------------
|
||
Return Value:
|
||
= 0: Successful completion
|
||
|
||
----------------------------------------------------------
|
||
Beispiel (optional):
|
||
|
||
----------------------------------------------------------
|
||
C4
|
||
void r_strcopy_purge_map( QMap<QString,QString> &theMap )
|
||
{
|
||
|
||
r_strcopy_purge_map
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy_purge_map> called" );
|
||
|
||
if ( !theMap.isEmpty() ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS
|
||
,"r_strcopy_purge_map> es gibt %d Elemente in der Map", theMap.count() );
|
||
|
||
QMap<QString,QString>::Iterator it;
|
||
for ( it = theMap.begin(); it != theMap.end(); ++it ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy_purge_map> key [%s] geloescht"
|
||
,it.key().latin1() );
|
||
|
||
}
|
||
theMap.clear();
|
||
|
||
}
|
||
return;
|
||
|
||
}
|
||
|
||
r_strcopy_is_key_in_map (6_testmodul_pool-testlisten_module-r_rechenmodule-r_strcopy)
|
||
SDOperation
|
||
|
||
History
|
||
-------
|
||
created by ohm3sa 07/21/1998 at 13:54
|
||
modified by klm3sa 01/14/2000 at 09:58
|
||
|
||
SD text
|
||
-------
|
||
C3
|
||
----------------------------------------------------------
|
||
Kurzbeschreibung: prueft ob eine Eintrag vorhanden ist
|
||
|
||
----------------------------------------------------------
|
||
Schnittstelle:
|
||
#include <...h>
|
||
|
||
$Function$
|
||
|
||
----------------------------------------------------------
|
||
Funktionsbeschreibung:
|
||
|
||
Input:
|
||
|
||
Output:
|
||
none
|
||
|
||
----------------------------------------------------------
|
||
Return Value:
|
||
= 0: Successful completion
|
||
|
||
----------------------------------------------------------
|
||
Beispiel (optional):
|
||
|
||
----------------------------------------------------------
|
||
C4
|
||
int r_strcopy_is_key_in_map( const QMap<QString,QString> &theMap, const QString &key_element )
|
||
{
|
||
|
||
r_strcopy_is_key_in_map
|
||
|
||
Lokale Variablen
|
||
int ret_val = 0;
|
||
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy_is_element_in_map> called with [%s]"
|
||
,(const char *)key_element );
|
||
|
||
if ( !theMap.isEmpty() ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS
|
||
,"r_strcopy_is_element_in_map> es gibt %d Elemente in der Map", theMap.count() );
|
||
|
||
QMap<QString,QString>::ConstIterator it;
|
||
for ( it = theMap.begin(); it != theMap.end(); ++it ) {
|
||
debug_message( __FILE__, __LINE__, DEB_STATUS, "r_strcopy_is_key_in_map> key_in_map: [%s]"
|
||
,it.key().latin1() );
|
||
|
||
if ( it.key() == key_element ) {
|
||
ret_val = 1;
|
||
break;
|
||
|
||
}
|
||
}
|
||
}
|
||
return( ret_val );
|
||
|
||
}
|
||
</PRE>
|
||
</BODY>
|
||
</HTML>
|