- Main Page
- Related Pages
- Modules
- Classes
- Files

# StringCollection.h

Go to the documentation of this file.

    00001 #ifndef FDO_STRING_COLLECTION_H
    00002 #define FDO_STRING_COLLECTION_H     1
    00003 //
    00004
    00005 //
    00006 // Copyright (C) 2004-2006  Autodesk, Inc.
    00007 //
    00008 // This library is free software; you can redistribute it and/or
    00009 // modify it under the terms of version 2.1 of the GNU Lesser
    00010 // General Public License as published by the Free Software Foundation.
    00011 //
    00012 // This library is distributed in the hope that it will be useful,
    00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015 // Lesser General Public License for more details.
    00016 //
    00017 // You should have received a copy of the GNU Lesser General Public
    00018 // License along with this library; if not, write to the Free Software
    00019 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00020 //
    00021
    00022 #ifdef _WIN32
    00023 #pragma once
    00024 #endif
    00025
    00026 #include <Common/Collection.h>
    00027
    00028 /// \cond DOXYGEN-IGNORE
    00029 // An element in a string collection.
    00030 // This class is just a wrapper around a string.
    00031 class FdoStringElement : public FdoDisposable
    00032 {
    00033 public:
    00034     /// Create from a string.
    00035     static FdoStringElement* Create( FdoStringP src )
    00036     {
    00037         return new FdoStringElement(src);
    00038     }
    00039
    00040     /// Operator to copy from a "managed" string.
    00041     FdoStringElement& operator=( const FdoStringP& src )
    00042     {
    00043         mString = src;
    00044         return(*this);
    00045     }
    00046
    00047     /// Operator to copy from an "unmanaged" string.
    00048     FdoStringElement& operator=( FdoString* wString )
    00049     {
    00050         mString = wString;
    00051         return(*this);
    00052     }
    00053
    00054     /// Returns the string that this element represents.
    00055     FdoStringP GetString()
    00056     {
    00057         return mString;
    00058     }
    00059
    00060 protected:
    00061     /// Create from a string.
    00062     FdoStringElement() {}
    00063     FdoStringElement( FdoStringP src )
    00064     {
    00065         mString = src;
    00066     }
    00067
    00068     virtual ~FdoStringElement(void)
    00069     {
    00070     }
    00071
    00072 private:
    00073     FdoStringP mString;
    00074 };
    00075
    00076 typedef FdoPtr<FdoStringElement> FdoStringElementP;
    00077 /// \endcond
    00078
    00079 /// \brief
    00080 /// FdoStringCollection is a collection of strings.
    00081 class FdoStringCollection : public FdoCollection<FdoStringElement,FdoException>
    00082 {
    00083 public:
    00084     /// \brief
    00085     /// Constructs a new empty string collection
    00086     ///
    00087     /// \return
    00088     /// Returns FdoStringCollection
    00089     ///
    00090     FDO_API_COMMON static FdoStringCollection* Create(void);
    00091
    00092     /// \brief
    00093     /// Creates a copy of string collection
    00094     ///
    00095     /// \param src
    00096     /// Input the source collection
    00097     ///
    00098     /// \return
    00099     /// Returns FdoStringCollection
    00100     ///
    00101     FDO_API_COMMON static FdoStringCollection* Create( const FdoStringCollection& src);
    00102
    00103     /// \brief
    00104     /// Creates a copy of string collection
    00105     ///
    00106     /// \param src
    00107     /// Input pointer to the source collection
    00108     ///
    00109     /// \return
    00110     /// Returns FdoStringCollection
    00111     ///
    00112     FDO_API_COMMON static FdoStringCollection* Create( const FdoStringCollection* src);
    00113
    00114     /// \brief
    00115     /// Creates a string collection that is tokenize from a string.
    00116     /// The collection contains an element for each token.
    00117     ///
    00118     /// \param inString
    00119     /// Input the string to tokenize.
    00120     /// \param delimiters
    00121     /// Input list of single character token delimiters.
    00122     /// \param bNullTokens
    00123     /// true: include zero-length tokens in the collection.
    00124     /// false: exclude zero-length tokens
    00125     ///
    00126     /// \return
    00127     /// Returns FdoStringCollection
    00128     ///
    00129     FDO_API_COMMON static FdoStringCollection* Create( const FdoStringP& inString, FdoString* delimiters, bool bNullTokens = false );
    00130
    00131     /// \brief
    00132     /// Gets the string in the collection at the specified index. Throws an invalid argument exception if the index is out of range.
    00133     ///
    00134     /// \param index
    00135     /// Input index
    00136     ///
    00137     /// \return
    00138     /// Returns the string in the collection at the specified index
    00139     ///
    00140     FDO_API_COMMON FdoString* GetString(int index) const;
    00141
    00142     /// \brief
    00143     /// Appends the strings from src to the end of this collection.
    00144     ///
    00145     /// \param src
    00146     /// Input the source collection
    00147     ///
    00148     FDO_API_COMMON void Append( const FdoStringCollection& src);
    00149
    00150     /// \brief
    00151     /// Adds a string to the end of this collection.
    00152     ///
    00153     /// \param src
    00154     /// Input the source collection
    00155     ///
    00156     FDO_API_COMMON int Add( FdoStringP src);
    00157
    00158     /// \brief
    00159     /// Given a string, returns its position in this collection.
    00160     ///
    00161     /// \param value
    00162     /// Input the string to check
    00163     /// \param caseSensitive
    00164     /// Input if true, do a case-sensitive comparison
    00165     /// of the string and members of this collection. If false, the comparison
    00166     /// is case-insensitive.
    00167     ///
    00168     /// \return
    00169     /// Returns the string's position. Returns -1 if the string
    00170     /// is not in this collection.
    00171     ///
    00172     FDO_API_COMMON virtual FdoInt32 IndexOf(FdoStringP value, FdoBoolean caseSensitive = true) const;
    00173
    00174     /// \brief
    00175     /// Concatenates the strings in this collection.
    00176     ///
    00177     /// \param separator
    00178     /// Input separate each collection string with this separator string.
    00179     ///
    00180     /// \return
    00181     /// Returns the concatenation if all strings in this collection.
    00182     ///
    00183     /// Returns a concatenation of all the strings in this collection,
    00184     /// separated by the given separator.
    00185     FDO_API_COMMON FdoStringP ToString( FdoString* separator = L", " );
    00186
    00187 protected:
    00188 /// \cond DOXYGEN-IGNORE
    00189     FDO_API_COMMON FdoStringCollection(void);
    00190     FDO_API_COMMON FdoStringCollection( const FdoStringCollection& src);
    00191     FDO_API_COMMON FdoStringCollection( const FdoStringCollection* src);
    00192     FDO_API_COMMON FdoStringCollection( const FdoStringP& inString, FdoString* delimiters, bool bNullTokens = false );
    00193
    00194     FDO_API_COMMON virtual ~FdoStringCollection(void);
    00195
    00196 /// \endcond
    00197     FDO_API_COMMON virtual void Dispose()
    00198     {
    00199         delete this;
    00200     }
    00201
    00202 private:
    00203 };
    00204
    00205 //typedef FdoPtr<FdoStringCollection> FdoStringsP;
    00206
    00207 /// \brief
    00208 /// FdoStringsP is a FdoPtr on FdoStringCollection, provided for convenience.
    00209 class FdoStringsP : public FdoPtr<FdoStringCollection>
    00210 {
    00211 public:
    00212     FdoStringsP() {}
    00213     FdoStringsP( const FdoStringsP& src )
    00214         : FdoPtr<FdoStringCollection>(src)
    00215     {}
    00216
    00217     FdoStringsP( FdoStringCollection* src )
    00218         : FdoPtr<FdoStringCollection>(src)
    00219     {}
    00220
    00221     ~FdoStringsP() {}
    00222     /// \brief
    00223     /// Copies a string collection
    00224     ///
    00225     /// \param src
    00226     /// Input the source collection
    00227     ///
    00228     /// \return
    00229     /// Returns the copy FdoStringCollection
    00230     ///
    00231     FDO_API_COMMON FdoStringCollection* operator=( FdoStringCollection* src );
    00232
    00233     /// \brief
    00234     /// Concatenates two string collections
    00235     ///
    00236     /// \param coll2
    00237     /// Input collection to append to the end of this collection
    00238     ///
    00239     /// \return
    00240     /// Returns the concatenated FdoStringCollection
    00241     ///
    00242     FDO_API_COMMON const FdoStringsP operator+( const FdoStringsP coll2 ) const;
    00243
    00244     /// \brief
    00245     /// Concatenates a string collection and a string
    00246     ///
    00247     /// \param str2
    00248     /// Input stromg to append to the end of this collection
    00249     ///
    00250     /// \return
    00251     /// Returns the concatenated FdoStringCollection
    00252     ///
    00253     FDO_API_COMMON const FdoStringsP operator+( const FdoStringP str2 ) const;
    00254
    00255     /// \brief
    00256     /// Concatenates two string collections
    00257     ///
    00258     /// \param coll2
    00259     /// Input collection to append to the end of this collection
    00260     ///
    00261     /// \return
    00262     /// Returns the concatenated FdoStringCollection
    00263     ///
    00264     FDO_API_COMMON FdoStringsP operator+=( FdoStringsP coll2 );
    00265
    00266     /// \brief
    00267     /// Concatenates a string collection and a string
    00268     ///
    00269     /// \param str2
    00270     /// Input stromg to append to the end of this collection
    00271     ///
    00272     /// \return
    00273     /// Returns the concatenated FdoStringCollection
    00274     ///
    00275     FDO_API_COMMON FdoStringsP operator+=( FdoStringP str2 );
    00276
    00277 };
    00278
    00279 #endif
    00280
    00281

Please send us your comment about this page