From 2aab5ea2773b8a73156a2c4cc47bc00b6f87d669 Mon Sep 17 00:00:00 2001 From: Mattia Tollari Date: Tue, 11 Jun 2019 11:07:47 +0200 Subject: [PATCH] Patch level : 12.0 no-patch Files correlati : include Commento : - Aggiunti nuovi files a lffiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implementate funzioni in TString - replace(const char*, const char*): sostituisce una stringa con quella passata (prima c'era solo la versione con char) - contains(char, int): controlla se la stringa contiene il carattere passato - contains(const char*, int): controlla se la stringa contiene la stringa passata Implementata funzione in TToken_string: - const char* remove(int): rimuove un token dalla stringa e lo ritorna - Aggiunta funzione is_multi_table(int) in utility.h che ritorna se il file รจ un multitracciato --- src/include/lffiles.h | 4 ++++ src/include/strings.cpp | 45 +++++++++++++++++++++++++++++++++-------- src/include/strings.h | 8 ++++++++ src/include/utility.h | 4 ++++ 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/include/lffiles.h b/src/include/lffiles.h index bd3da435e..4e11af404 100755 --- a/src/include/lffiles.h +++ b/src/include/lffiles.h @@ -193,6 +193,10 @@ #define LF_TRASFATT 173 #define LF_IVALIQ 174 #define LF_CFPRI 175 +#define LF_FPCUST 176 +#define LF_FPCCAUS 177 +#define LF_FPCART 178 +#define LF_FPCADG 179 #define LF_EXTERNAL 1000 // Files with id >= are considered to be externals diff --git a/src/include/strings.cpp b/src/include/strings.cpp index e2599d9bf..e9bfa50cc 100755 --- a/src/include/strings.cpp +++ b/src/include/strings.cpp @@ -411,6 +411,21 @@ int TString::replace(char find_char, char replace_char) return n; } +int TString::replace(const char* find_string, const char* replace_string) +{ + int n = 0; + const int old_str_lenght = strlen(find_string); + const int new_str_lenght = strlen(replace_string); + for(int pos = find(find_string); pos >= 0; pos = find(find_string, pos + new_str_lenght)) + { + static TString app; app.cut(0); + app << this->left(pos) << replace_string << this->mid(pos + old_str_lenght); + *this = app; + n++; + } + return n; +} + // Certified 99% // @doc EXTERNAL @@ -1013,14 +1028,14 @@ TString& TString::insert( strcpy_s(&_str[pos+l], _size-(pos+l)+1, spark); // Aggiungi spark } return *this; -} - -TString & TString::add_front(const char * s) -{ - const int l = strlen(s); - lpad(len() + l); - overwrite(s); - return *this; +} + +TString & TString::add_front(const char * s) +{ + const int l = strlen(s); + lpad(len() + l); + overwrite(s); + return *this; } // Certified 90% @@ -1941,6 +1956,20 @@ void TToken_string::destroy(int n) restart(); } +const char* TToken_string::remove(const int pos) +{ + // Prelevo l'informazione della stringa + TString& ret = get_tmp_string(); + ret << get(pos); + + // La distruggo nel TToken_string + destroy(pos); + + // Ritorno + return ret; +} + + TToken_string& TToken_string::pack() { const char sep = separator(); diff --git a/src/include/strings.h b/src/include/strings.h index c91b72d07..b1a8802f3 100755 --- a/src/include/strings.h +++ b/src/include/strings.h @@ -113,6 +113,12 @@ public: int find(const char* s, int from = 0) const; // @cmember Sostituisce le occorrenze di

col carattere

int replace(char find_char, char replace_char); + // @cmember Sostituisce le occorrenze di

col carattere

+ int replace(const char * find_string, const char* replace_string); + // @cmember Ritorna se ่ contenuta almeno un'occorrenza del carattere c nell'oggetto TString + bool contains(const char c, const int from = 0) const { return find(c, from) >= 0; } + // @cmember Ritorna se ่ contenuta almeno un'occorrenza della stringa s nell'oggetto TString + bool contains(const char* s, const int from = 0) const { return find(s, from) >= 0; } // @cmember Ritorna l'oggetto TString composto dai count caratteri da sinistra const TString& left(int count) const; @@ -648,6 +654,8 @@ public: void insert_at(const char* s, int n); // @cmember Toglie la stringa di posizione pos void destroy(int pos); + // @cmember Toglie la stringa di posizione pos e la ritorna + const char* remove(int pos); // @cmember Ritorna il prossimo token const char* get(); diff --git a/src/include/utility.h b/src/include/utility.h index 947523a19..84aada0f7 100755 --- a/src/include/utility.h +++ b/src/include/utility.h @@ -13,11 +13,14 @@ #include #endif +#include + #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) #define SAFE_DELETE(p) { delete p; p = NULL; } #define DEBUG_ENABLED is_debug_station() + class TPerformance_profiler : public TObject { TString _desc; @@ -76,4 +79,5 @@ inline const char* get_iva_sirio() // Ritorna la partita IVA della Sirio TString& to_tstring(long n); TString& to_tstring(int n); +inline bool is_multi_table(const int file) { return file == LF_TAB || file == LF_TABGEN || file == LF_TABCOM || file == LF_TABMOD; } #endif /* __UTILITY_H */