DumontEXE 0.0.1
cmcStringList.h
00001 /* ***************************************************************************
00002 **
00003 ** Copyright (C) 2007 Lorimark Solutions, LLC. All rights reserved.
00004 **
00005 ** This file is part of the DumontEXE Scripting Extension Kit
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://dumont.showoff-db.org/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://dumont.showoff-db.org/licensing.html 
00017 ** or contact the sales department at sales@lorimarksolutions.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ** author: Mark Petryk ~ Lorimark Solutions, LLC
00023 ** **************************************************************************/
00024 
00025 #ifndef CDA_STRINGLIST_H_422FD07F_0597_4cbb_A034_9AE85166472E
00026 #define CDA_STRINGLIST_H_422FD07F_0597_4cbb_A034_9AE85166472E
00027 
00028 #include <QMetaType>
00029 #include <QObject>
00030 #include <QStringList>
00031 
00032 namespace cmcDatabaseApi {
00033 
00034 /*!
00035 ** \brief Cmc StringList Object
00036 **
00037 ** This object is designed to provide a simple, fast, string-list
00038 **  interface for vbScript.  Why?  Because, vbScript multi-string handling
00039 **  is... a pain! Especially when it comes to multiple listed items,
00040 **  like items that might be found in a dimmensioned array sort of
00041 **  affair.  In vbScript, assembling those arrays of string is...
00042 **  well... more work than it needs to be.  This object encapsulates
00043 **  a variable-length, auto-sized array of strings that are easy 
00044 **  to access and manipulate.
00045 **
00046 ** This object is ideal for assembling dynamic lists, when the 
00047 **  number of items in the list is not known until it is fully assembled,
00048 **  and during assembly it is possible that some duplicate items might
00049 **  be processed, and you want them automatically eliminated from the
00050 **  final list.
00051 **
00052 ** \par vbScript Example ~ Using the String List object
00053 ** \code
00054 ** dim dexe: set dexe = createObject( "Dumont.EXE" )
00055 ** dim dlog: set dlog = dexe.logWindow("dstr demo")
00056 ** dim dstr: set dstr = dexe.getStringList ' no duplicates (default)
00057 **
00058 ** dstr.append "one"
00059 ** dstr.append "two"
00060 ** dstr.append "tre"
00061 ** dstr.append "one"
00062 **
00063 ** dim i: for i = 0 to dstr.count - 1
00064 **   dlog.print dstr.item(i)
00065 ** next
00066 **
00067 ** '
00068 ** ' output should be:
00069 ** '  'one'
00070 ** '  'two'
00071 ** '  'tre'
00072 ** \endcode
00073 **
00074 ** Note that the output from this function does not output the
00075 **  additional duplicate "one" value.  That's because the string list
00076 **  object was requested to not allow duplicates.  Optionally the
00077 **  string list object can be constructed to allow duplicates:
00078 **
00079 ** \par vbScript Example ~ Allowing Duplicates
00080 ** \code
00081 ** const cmcStringList_allowDupes = 1
00082 ** dim dstr: set dstr = dexe.getStringList(cmcStringList_allowDupes)
00083 ** \endcode
00084 **
00085 ** Using the string list object constructed in this fashion causes it
00086 **  to allow duplicate strings to be appended to it.
00087 **
00088 */
00089 class cmcStringList:
00090   public QObject
00091 {
00092   Q_OBJECT
00093   public:
00094 
00095     /*!
00096     ** \brief Copy Constructor \n
00097     **
00098     */
00099     cmcStringList( const cmcStringList & copy );
00100 
00101     /*!
00102     ** \brief General Constructor \n
00103     **
00104     */
00105     cmcStringList( long flags = 0, QObject * parent = NULL );
00106 
00107     cmcStringList( const QString & listName, long flags = 0, QObject * parent = NULL );
00108 
00109     virtual ~cmcStringList();
00110 
00111     void append( const QStringList & stringList );
00112 
00113     QStringList stringList();
00114     void setStringList( const QStringList & strings );
00115 
00116   public slots:
00117 
00118     /*!
00119     ** \brief Clear the List \n
00120     **
00121     ** This removes all the items from the list.
00122     **
00123     */
00124     void clear();
00125 
00126     /*!
00127     ** \brief Prepend \n
00128     **
00129     ** Add an item to the beginning of the list
00130     **
00131     */
00132     void prepend
00133     (
00134       /*! string ~ text to prepend */
00135       const QString & string
00136     );
00137 
00138     /*!
00139     ** \brief Take First \n
00140     **
00141     ** Take the first item from the list.
00142     **
00143     */
00144     QString takeFirst();
00145 
00146     /*!
00147     ** \brief Take Last \n
00148     **
00149     ** Take the last item from the list.
00150     **
00151     */
00152     QString takeLast();
00153 
00154     /*!
00155     ** \brief Take an Item \n
00156     **
00157     ** Take an item by index number.
00158     **
00159     */
00160     QString takeAt
00161     (
00162       /*! long ~ index of item to take */
00163       long index
00164     );
00165 
00166     /*!
00167     ** \brief Take an item \n
00168     **
00169     ** This removes an item from the list by value.
00170     **
00171     */
00172     bool removeOne
00173     (
00174       const QString & string
00175     );
00176 
00177     /*!
00178     ** \brief Append a string \n
00179     **
00180     **
00181     */
00182     void append
00183     (
00184       /*! string ~ append text */
00185       const QString & string
00186     );
00187 
00188     /*!
00189     ** \brief Fetch a string \n
00190     **
00191     **
00192     */
00193     QString item
00194     (
00195       /*! long ~ index of item to fetch */
00196       long index
00197     );
00198 
00199     /*!
00200     ** \brief Fetch a string \n
00201     **
00202     **
00203     */
00204     QString line
00205     (
00206       /*! long ~ index of line to fetch */
00207       long index
00208     );
00209 
00210     /*!
00211     ** \brief Single Delimited String \n
00212     **
00213     **
00214     */
00215     QString join
00216     (
00217       /*! string ~ separator (defaults to vbCrLf) */
00218       const QString & separator = "\r\n"
00219     );
00220 
00221     /*!
00222     ** \brief Count the strings \n
00223     **
00224     */
00225     long count();
00226 
00227     /*!
00228     ** \brief Duplicates flag \n
00229     **
00230     **
00231     */
00232     bool allowDupes();
00233 
00234   private:
00235 
00236     /*!
00237     ** \brief Stored Flags \n
00238     **
00239     */
00240     long m_flags;
00241 
00242     /*!
00243     ** \brief Stored Strings \n
00244     **
00245     */
00246     QStringList m_stringList;
00247 
00248 }; // endclass cmcStringList:
00249 
00250 } // endnamespace cmcDatabaseApi
00251 
00252 #endif // #ifndef CDA_STRINGLIST_H_422FD07F_0597_4cbb_A034_9AE85166472E
00253 
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties




~ ~ ~ ~ ~ ~
Source Code without Comments is like a Cranberry Garland
without the berries. Comment your Code!
 
Commence Database User Support Group Forum
http://newsgroup.showoff-db.org/
~ ~ ~ ~ ~ ~
Author: Mark Petryk
Lorimark Solutions, LLC
mark@lorimarksolutions.com