New data type FStringList introduced

This commit is contained in:
Markus Gans 2017-09-20 16:56:20 +02:00
parent c97511a6cc
commit b3e9a0bba1
15 changed files with 72 additions and 76 deletions

View File

@ -1,3 +1,6 @@
2017-09-20 Markus Gans <guru.mail@muenster.de>
* New data type FStringList introduced
2017-09-19 Markus Gans <guru.mail@muenster.de> 2017-09-19 Markus Gans <guru.mail@muenster.de>
* FString has now got its own streaming functionality for * FString has now got its own streaming functionality for
inbound and outbound type conversion inbound and outbound type conversion

View File

@ -19,7 +19,7 @@ automake --add-missing --copy
#autoreconf -v --install --force #autoreconf -v --install --force
echo echo
echo 'run "./configure ; make"' echo 'run "./configure --prefix=/usr && make"'
echo echo
# Generate Makefile from Makefile.in # Generate Makefile from Makefile.in

View File

@ -111,7 +111,7 @@ Listview::Listview (FWidget* parent)
for (int i = 0; i <= lastItem; i++) for (int i = 0; i <= lastItem; i++)
{ {
std::vector<FString> line (&weather[i][0], &weather[i][0] + 5); FStringList line (&weather[i][0], &weather[i][0] + 5);
listView->insert (line); listView->insert (line);
} }

View File

@ -321,8 +321,8 @@ int main (int, char**)
FString split_str = "a,b,c,d"; FString split_str = "a,b,c,d";
std::cout << " split: \"" std::cout << " split: \""
<< split_str << "\" into substrings ->"; << split_str << "\" into substrings ->";
std::vector <FString> parts = split_str.split(","); FStringList parts = split_str.split(",");
std::vector<FString>::iterator it, end; FStringList::iterator it, end;
end = parts.end(); end = parts.end();
for (it = parts.begin(); it != end; ++it) for (it = parts.begin(); it != end; ++it)

View File

@ -76,14 +76,14 @@ Treeview::Treeview (FWidget* parent)
for (int i = 0; i <= lastItem; i++) for (int i = 0; i <= lastItem; i++)
{ {
std::vector<FString> line (&continent[i][0], &continent[i][0] + 3); FStringList line (&continent[i][0], &continent[i][0] + 3);
listView->insert (line); listView->insert (line);
} }
FObjectIterator iter_africa = listView->beginOfList(); FObjectIterator iter_africa = listView->beginOfList();
std::string egypt[3] = { "Egypt", "94,666,000", "87" }; std::string egypt[3] = { "Egypt", "94,666,000", "87" };
std::vector<FString> egypt_line (&egypt[0], &egypt[0] + 3); FStringList egypt_line (&egypt[0], &egypt[0] + 3);
//FObjectIterator iter_africa = listView->insert (egypt_line); //FObjectIterator iter_africa = listView->insert (egypt_line);
listView->insert (egypt_line, iter_africa); listView->insert (egypt_line, iter_africa);

View File

@ -105,9 +105,6 @@ class FLabel : public FWidget
void cb_accel_widget_destroyed (FWidget*, data_ptr); void cb_accel_widget_destroyed (FWidget*, data_ptr);
private: private:
// Typedef
typedef std::vector<FString> multiLineText;
// Disable copy constructor // Disable copy constructor
FLabel (const FLabel&); FLabel (const FLabel&);
@ -124,7 +121,7 @@ class FLabel : public FWidget
void draw(); void draw();
// Data Members // Data Members
multiLineText multiline_text; FStringList multiline_text;
bool multiline; bool multiline;
FString text; FString text;
fc::text_alignment alignment; fc::text_alignment alignment;

View File

@ -54,7 +54,7 @@ class FListViewItem : public FObject
// Constructor // Constructor
FListViewItem (const FListViewItem&); // copy constructor FListViewItem (const FListViewItem&); // copy constructor
explicit FListViewItem (FObjectIterator); explicit FListViewItem (FObjectIterator);
FListViewItem ( const std::vector<FString>& FListViewItem ( const FStringList&
, FWidget::data_ptr , FWidget::data_ptr
, FObjectIterator ); , FObjectIterator );
@ -92,11 +92,11 @@ class FListViewItem : public FObject
int getVisibleLines(); int getVisibleLines();
// Data Member // Data Member
std::vector<FString> column_list; FStringList column_list;
FWidget::data_ptr data_pointer; FWidget::data_ptr data_pointer;
int visible_lines; int visible_lines;
bool expandable; bool expandable;
bool is_expand; bool is_expand;
// Friend class // Friend class
friend class FListView; friend class FListView;
@ -160,11 +160,11 @@ class FListView : public FWidget
virtual int addColumn (const FString&, int = USE_MAX_SIZE); virtual int addColumn (const FString&, int = USE_MAX_SIZE);
FObjectIterator insert (FListViewItem*); FObjectIterator insert (FListViewItem*);
FObjectIterator insert (FListViewItem*, FObjectIterator); FObjectIterator insert (FListViewItem*, FObjectIterator);
FObjectIterator insert ( const std::vector<FString>& FObjectIterator insert ( const FStringList&
, data_ptr = 0 ); , data_ptr = 0 );
FObjectIterator insert ( const std::vector<FString>& FObjectIterator insert ( const FStringList&
, FObjectIterator ); , FObjectIterator );
FObjectIterator insert ( const std::vector<FString>& FObjectIterator insert ( const FStringList&
, data_ptr , data_ptr
, FObjectIterator ); , FObjectIterator );
FObjectIterator insert ( const std::vector<long>& FObjectIterator insert ( const std::vector<long>&
@ -306,12 +306,12 @@ inline FObject::FObjectIterator FListView::insert (FListViewItem* item)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator inline FObject::FObjectIterator
FListView::insert ( const std::vector<FString>& cols, data_ptr d ) FListView::insert ( const FStringList& cols, data_ptr d )
{ return insert (cols, d, root); } { return insert (cols, d, root); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator inline FObject::FObjectIterator
FListView::insert ( const std::vector<FString>& cols FListView::insert ( const FStringList& cols
, FObjectIterator parent_iter ) , FObjectIterator parent_iter )
{ return insert (cols, 0, parent_iter); } { return insert (cols, 0, parent_iter); }

View File

@ -122,9 +122,6 @@ class FMessageBox : public FDialog
void cb_processClick (FWidget*, data_ptr); void cb_processClick (FWidget*, data_ptr);
private: private:
// Typedef
typedef std::vector<FString> textLines;
// Methods // Methods
void init (int, int, int); void init (int, int, int);
void calculateDimensions(); void calculateDimensions();
@ -136,7 +133,7 @@ class FMessageBox : public FDialog
FString headline_text; FString headline_text;
FString text; FString text;
FString* text_components; FString* text_components;
textLines text_split; FStringList text_split;
uInt max_line_width; uInt max_line_width;
bool center_text; bool center_text;
short emphasis_color; short emphasis_color;

View File

@ -33,6 +33,11 @@
#include "final/ftypes.h" #include "final/ftypes.h"
// class forward declaration
class FString;
// Global typedef
typedef std::vector<FString> FStringList;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FString // class FString
@ -230,13 +235,13 @@ class FString
FString mid (int, int) const; FString mid (int, int) const;
FString mid (uInt, uInt) const; FString mid (uInt, uInt) const;
std::vector<FString> split (const FString&); FStringList split (const FString&);
std::vector<FString> split (const std::wstring&); FStringList split (const std::wstring&);
std::vector<FString> split (const wchar_t*); FStringList split (const wchar_t*);
std::vector<FString> split (const std::string&); FStringList split (const std::string&);
std::vector<FString> split (const char*); FStringList split (const char*);
std::vector<FString> split (const wchar_t); FStringList split (const wchar_t);
std::vector<FString> split (const char); FStringList split (const char);
FString& setString (const wchar_t*); FString& setString (const wchar_t*);
FString& setString (const char*); FString& setString (const char*);
@ -390,27 +395,27 @@ inline wchar_t FString::back() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::vector<FString> FString::split (const std::wstring& s) inline FStringList FString::split (const std::wstring& s)
{ return split(FString(s)); } { return split(FString(s)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::vector<FString> FString::split (const wchar_t* s) inline FStringList FString::split (const wchar_t* s)
{ return split(FString(s)); } { return split(FString(s)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::vector<FString> FString::split (const std::string& s) inline FStringList FString::split (const std::string& s)
{ return split(FString(s)); } { return split(FString(s)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::vector<FString> FString::split (const char* s) inline FStringList FString::split (const char* s)
{ return split(FString(s)); } { return split(FString(s)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::vector<FString> FString::split (const wchar_t c) inline FStringList FString::split (const wchar_t c)
{ return split(FString(c)); } { return split(FString(c)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::vector<FString> FString::split (const char c) inline FStringList FString::split (const char c)
{ return split(FString(c)); } { return split(FString(c)); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -50,9 +50,6 @@ class FTextView : public FWidget
// Using-declarations // Using-declarations
using FWidget::setGeometry; using FWidget::setGeometry;
// Typedef
typedef std::vector<FString> stringLines;
// Constructor // Constructor
explicit FTextView (FWidget* = 0); explicit FTextView (FWidget* = 0);
@ -64,7 +61,7 @@ class FTextView : public FWidget
uInt getColumns() const; uInt getColumns() const;
uInt getRows() const; uInt getRows() const;
const FString getText() const; const FString getText() const;
const stringLines& getLines() const; const FStringList& getLines() const;
// Mutators // Mutators
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
@ -101,23 +98,23 @@ class FTextView : public FWidget
FTextView& operator = (const FTextView&); FTextView& operator = (const FTextView&);
// Methods // Methods
void init(); void init();
void draw(); void draw();
void drawText(); void drawText();
void processChanged(); void processChanged();
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, data_ptr); void cb_VBarChange (FWidget*, data_ptr);
void cb_HBarChange (FWidget*, data_ptr); void cb_HBarChange (FWidget*, data_ptr);
// Data Members // Data Members
stringLines data; FStringList data;
FScrollbar* vbar; FScrollbar* vbar;
FScrollbar* hbar; FScrollbar* hbar;
int xoffset; int xoffset;
int yoffset; int yoffset;
int nf_offset; int nf_offset;
uInt maxLineWidth; uInt maxLineWidth;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -136,7 +133,7 @@ inline uInt FTextView::getRows() const
{ return uInt(data.size()); } { return uInt(data.size()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FTextView::stringLines& FTextView::getLines() const inline const FStringList& FTextView::getLines() const
{ return data; } { return data; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -71,9 +71,6 @@ class FToolTip : public FWindow
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
private: private:
// Typedef
typedef std::vector<FString> textLines;
// Disable copy constructor // Disable copy constructor
FToolTip (const FToolTip&); FToolTip (const FToolTip&);
@ -88,7 +85,7 @@ class FToolTip : public FWindow
// Data Members // Data Members
FString text; FString text;
FString* text_components; FString* text_components;
textLines text_split; FStringList text_split;
uInt max_line_width; uInt max_line_width;
uInt text_num_lines; uInt text_num_lines;
}; };

View File

@ -52,7 +52,7 @@ FListViewItem::FListViewItem (FObjectIterator parent_iter)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FListViewItem::FListViewItem ( const std::vector<FString>& cols FListViewItem::FListViewItem ( const FStringList& cols
, FWidget::data_ptr data , FWidget::data_ptr data
, FObjectIterator parent_iter ) , FObjectIterator parent_iter )
: FObject(0) : FObject(0)
@ -195,7 +195,7 @@ FObject::FObjectIterator FListViewItem::appendItem (FListViewItem* child)
void FListViewItem::replaceControlCodes() void FListViewItem::replaceControlCodes()
{ {
// Replace the control codes characters // Replace the control codes characters
std::vector<FString>::iterator iter = column_list.begin(); FStringList::iterator iter = column_list.begin();
while ( iter != column_list.end() ) while ( iter != column_list.end() )
{ {
@ -432,7 +432,7 @@ FObject::FObjectIterator FListView::insert ( FListViewItem* item
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListView::insert ( const std::vector<FString>& cols FObject::FObjectIterator FListView::insert ( const FStringList& cols
, data_ptr d , data_ptr d
, FObjectIterator parent_iter ) , FObjectIterator parent_iter )
{ {
@ -464,7 +464,7 @@ FObject::FObjectIterator FListView::insert ( const std::vector<long>& cols
, FObjectIterator parent_iter ) , FObjectIterator parent_iter )
{ {
FObjectIterator item_iter; FObjectIterator item_iter;
std::vector<FString> str_cols; FStringList str_cols;
if ( ! cols.empty() ) if ( ! cols.empty() )
{ {

View File

@ -1154,27 +1154,27 @@ FString FString::mid (uInt pos, uInt len) const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::vector<FString> FString::split (const FString& delimiter) FStringList FString::split (const FString& delimiter)
{ {
wchar_t* rest; wchar_t* rest;
wchar_t* token; wchar_t* token;
FString s(string); FString s(string);
std::vector<FString> stringList; FStringList string_list;
// handle NULL and empty string // handle NULL and empty string
if ( ! (string && *string) ) if ( ! (string && *string) )
return stringList; return string_list;
rest = 0; rest = 0;
token = extractToken(&rest, s.string, delimiter.wc_str()); token = extractToken(&rest, s.string, delimiter.wc_str());
while ( token ) while ( token )
{ {
stringList.push_back (FString(token)); string_list.push_back (FString(token));
token = extractToken (&rest, 0, delimiter.wc_str()); token = extractToken (&rest, 0, delimiter.wc_str());
} }
return stringList; return string_list;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2217,7 +2217,7 @@ FString FString::replaceControlCodes() const
FString FString::expandTabs (int tabstop) const FString FString::expandTabs (int tabstop) const
{ {
uLong last; uLong last;
std::vector<FString> tab_split; FStringList tab_split;
FString instr(string); FString instr(string);
FString outstr; FString outstr;

View File

@ -2722,16 +2722,16 @@ char* FTerm::parseSecDA (char*& current_termtype)
// remove the last byte ("c") // remove the last byte ("c")
temp.remove(temp.getLength() - 1, 1); temp.remove(temp.getLength() - 1, 1);
// split into components // split into components
std::vector<FString> sec_da_split = temp.split(';'); FStringList sec_da_list = temp.split(';');
num_components = sec_da_split.size(); num_components = sec_da_list.size();
if ( num_components == 3 ) if ( num_components == 3 )
sec_da_supported = true; sec_da_supported = true;
if ( num_components >= 2 ) if ( num_components >= 2 )
{ {
const FString* sec_da_components = &sec_da_split[0]; const FString* sec_da_components = &sec_da_list[0];
if ( ! sec_da_components[0].isEmpty() ) if ( ! sec_da_components[0].isEmpty() )
{ {

View File

@ -182,8 +182,8 @@ void FTextView::append (const FString& str)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::insert (const FString& str, int pos) void FTextView::insert (const FString& str, int pos)
{ {
stringLines::iterator iter; FStringList::iterator iter;
stringLines text_split; FStringList text_split;
FString s; FString s;
uLong num; uLong num;
@ -241,7 +241,7 @@ void FTextView::insert (const FString& str, int pos)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::replaceRange (const FString& str, int from, int to) void FTextView::replaceRange (const FString& str, int from, int to)
{ {
stringLines::iterator iter; FStringList::iterator iter;
if ( from > to ) if ( from > to )
return; return;