[fdo-commits] r2696 - in trunk/Fdo/Python: Inc Inc/Common Src/Common
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Mon Mar 19 19:59:49 EDT 2007
Author: gregboone
Date: 2007-03-19 19:59:49 -0400 (Mon, 19 Mar 2007)
New Revision: 2696
Added:
trunk/Fdo/Python/Inc/Common/StringCollection.h
trunk/Fdo/Python/Inc/Common/Vector.h
Modified:
trunk/Fdo/Python/Inc/stdafx.h
trunk/Fdo/Python/Src/Common/StringBuffer.cpp
Log:
Ticket #39: Add Linux Makefile Support -- Work In Progress
Added: trunk/Fdo/Python/Inc/Common/StringCollection.h
===================================================================
--- trunk/Fdo/Python/Inc/Common/StringCollection.h (rev 0)
+++ trunk/Fdo/Python/Inc/Common/StringCollection.h 2007-03-19 23:59:49 UTC (rev 2696)
@@ -0,0 +1,281 @@
+#ifndef FDO_STRING_COLLECTION_H
+#define FDO_STRING_COLLECTION_H 1
+//
+
+//
+// Copyright (C) 2004-2006 Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <Common/Collection.h>
+
+/// \cond DOXYGEN-IGNORE
+// An element in a string collection.
+// This class is just a wrapper around a string.
+class FdoStringElement : public FdoDisposable
+{
+public:
+ /// Create from a string.
+ static FdoStringElement* Create( FdoStringP src )
+ {
+ return new FdoStringElement(src);
+ }
+
+ /// Operator to copy from a "managed" string.
+ FdoStringElement& operator=( const FdoStringP& src )
+ {
+ mString = src;
+ return(*this);
+ }
+
+ /// Operator to copy from an "unmanaged" string.
+ FdoStringElement& operator=( FdoString* wString )
+ {
+ mString = wString;
+ return(*this);
+ }
+
+ /// Returns the string that this element represents.
+ FdoStringP GetString()
+ {
+ return mString;
+ }
+
+protected:
+ /// Create from a string.
+ FdoStringElement() {}
+ FdoStringElement( FdoStringP src )
+ {
+ mString = src;
+ }
+
+ virtual ~FdoStringElement(void)
+ {
+ }
+
+private:
+ FdoStringP mString;
+};
+
+typedef FdoPtr<FdoStringElement> FdoStringElementP;
+/// \endcond
+
+/// \brief
+/// FdoStringCollection is a collection of strings.
+class FdoStringCollection : public FdoCollection<FdoStringElement,FdoException>
+{
+public:
+ /// \brief
+ /// Constructs a new empty string collection
+ ///
+ /// \return
+ /// Returns FdoStringCollection
+ ///
+ FDO_API_COMMON static FdoStringCollection* Create(void);
+
+ /// \brief
+ /// Creates a copy of string collection
+ ///
+ /// \param src
+ /// Input the source collection
+ ///
+ /// \return
+ /// Returns FdoStringCollection
+ ///
+ FDO_API_COMMON static FdoStringCollection* Create( const FdoStringCollection& src);
+
+ /// \brief
+ /// Creates a copy of string collection
+ ///
+ /// \param src
+ /// Input pointer to the source collection
+ ///
+ /// \return
+ /// Returns FdoStringCollection
+ ///
+ FDO_API_COMMON static FdoStringCollection* Create( const FdoStringCollection* src);
+
+ /// \brief
+ /// Creates a string collection that is tokenize from a string.
+ /// The collection contains an element for each token.
+ ///
+ /// \param inString
+ /// Input the string to tokenize.
+ /// \param delimiters
+ /// Input list of single character token delimiters.
+ /// \param bNullTokens
+ /// true: include zero-length tokens in the collection.
+ /// false: exclude zero-length tokens
+ ///
+ /// \return
+ /// Returns FdoStringCollection
+ ///
+ FDO_API_COMMON static FdoStringCollection* Create( const FdoStringP& inString, FdoString* delimiters, bool bNullTokens = false );
+
+ /// \brief
+ /// Gets the string in the collection at the specified index. Throws an invalid argument exception if the index is out of range.
+ ///
+ /// \param index
+ /// Input index
+ ///
+ /// \return
+ /// Returns the string in the collection at the specified index
+ ///
+ FDO_API_COMMON FdoString* GetString(int index) const;
+
+ /// \brief
+ /// Appends the strings from src to the end of this collection.
+ ///
+ /// \param src
+ /// Input the source collection
+ ///
+ FDO_API_COMMON void Append( const FdoStringCollection& src);
+
+ /// \brief
+ /// Adds a string to the end of this collection.
+ ///
+ /// \param src
+ /// Input the source collection
+ ///
+ FDO_API_COMMON int Add( FdoStringP src);
+
+ /// \brief
+ /// Given a string, returns its position in this collection.
+ ///
+ /// \param value
+ /// Input the string to check
+ /// \param caseSensitive
+ /// Input if true, do a case-sensitive comparison
+ /// of the string and members of this collection. If false, the comparison
+ /// is case-insensitive.
+ ///
+ /// \return
+ /// Returns the string's position. Returns -1 if the string
+ /// is not in this collection.
+ ///
+ FDO_API_COMMON virtual FdoInt32 IndexOf(FdoStringP value, FdoBoolean caseSensitive = true) const;
+
+ /// \brief
+ /// Concatenates the strings in this collection.
+ ///
+ /// \param separator
+ /// Input separate each collection string with this separator string.
+ ///
+ /// \return
+ /// Returns the concatenation if all strings in this collection.
+ ///
+ /// Returns a concatenation of all the strings in this collection,
+ /// separated by the given separator.
+ FDO_API_COMMON FdoStringP ToString( FdoString* separator );
+
+protected:
+/// \cond DOXYGEN-IGNORE
+ FDO_API_COMMON FdoStringCollection(void);
+ FDO_API_COMMON FdoStringCollection( const FdoStringCollection& src);
+ FDO_API_COMMON FdoStringCollection( const FdoStringCollection* src);
+ FDO_API_COMMON FdoStringCollection( const FdoStringP& inString, FdoString* delimiters, bool bNullTokens = false );
+
+ FDO_API_COMMON virtual ~FdoStringCollection(void);
+
+/// \endcond
+ FDO_API_COMMON virtual void Dispose()
+ {
+ delete this;
+ }
+
+private:
+};
+
+//typedef FdoPtr<FdoStringCollection> FdoStringsP;
+
+/// \brief
+/// FdoStringsP is a FdoPtr on FdoStringCollection, provided for convenience.
+class FdoStringsP : public FdoPtr<FdoStringCollection>
+{
+public:
+ FdoStringsP() {}
+ FdoStringsP( const FdoStringsP& src )
+ : FdoPtr<FdoStringCollection>(src)
+ {}
+
+ FdoStringsP( FdoStringCollection* src )
+ : FdoPtr<FdoStringCollection>(src)
+ {}
+
+ ~FdoStringsP() {}
+ /// \brief
+ /// Copies a string collection
+ ///
+ /// \param src
+ /// Input the source collection
+ ///
+ /// \return
+ /// Returns the copy FdoStringCollection
+ ///
+ FDO_API_COMMON FdoStringCollection* operator=( FdoStringCollection* src );
+
+ /// \brief
+ /// Concatenates two string collections
+ ///
+ /// \param coll2
+ /// Input collection to append to the end of this collection
+ ///
+ /// \return
+ /// Returns the concatenated FdoStringCollection
+ ///
+ FDO_API_COMMON const FdoStringsP operator+( const FdoStringsP coll2 ) const;
+
+ /// \brief
+ /// Concatenates a string collection and a string
+ ///
+ /// \param str2
+ /// Input stromg to append to the end of this collection
+ ///
+ /// \return
+ /// Returns the concatenated FdoStringCollection
+ ///
+ FDO_API_COMMON const FdoStringsP operator+( const FdoStringP str2 ) const;
+
+ /// \brief
+ /// Concatenates two string collections
+ ///
+ /// \param coll2
+ /// Input collection to append to the end of this collection
+ ///
+ /// \return
+ /// Returns the concatenated FdoStringCollection
+ ///
+ FDO_API_COMMON FdoStringsP operator+=( FdoStringsP coll2 );
+
+ /// \brief
+ /// Concatenates a string collection and a string
+ ///
+ /// \param str2
+ /// Input stromg to append to the end of this collection
+ ///
+ /// \return
+ /// Returns the concatenated FdoStringCollection
+ ///
+ FDO_API_COMMON FdoStringsP operator+=( FdoStringP str2 );
+
+};
+
+#endif
+
+
Added: trunk/Fdo/Python/Inc/Common/Vector.h
===================================================================
--- trunk/Fdo/Python/Inc/Common/Vector.h (rev 0)
+++ trunk/Fdo/Python/Inc/Common/Vector.h 2007-03-19 23:59:49 UTC (rev 2696)
@@ -0,0 +1,408 @@
+#ifndef FDO_VECTOR_H
+#define FDO_VECTOR_H 1
+//
+
+//
+// Copyright (C) 2004-2006 Autodesk, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <Common/Collection.h>
+
+/// \brief
+/// An element in a vector.
+/// This class is just a ref-countable wrapper around a double.
+class FdoVectorElement : public FdoDisposable
+{
+public:
+ /// \brief
+ /// Creates a vector element.
+ ///
+ /// \param value
+ /// Input the value to assign the element
+ ///
+ /// \return
+ /// Returns FdoProviderNameTokens
+ ///
+ FDO_API_COMMON static FdoVectorElement* Create( double value )
+ {
+ return new FdoVectorElement(value);
+ }
+
+ /// \brief
+ /// Gets the element value.
+ ///
+ /// \return
+ /// Returns the value that this element represents.
+ ///
+ FDO_API_COMMON double GetValue()
+ {
+ return mValue;
+ }
+
+ /// \brief
+ /// Sets the element value.
+ ///
+ /// \param value
+ /// Input the value to assign the element
+ ///
+ FDO_API_COMMON void SetValue( double value )
+ {
+ mValue = value;
+ }
+
+ /// \brief
+ /// Gets the element value in string format.
+ ///
+ /// \return
+ /// Returns the value that this element represents.
+ ///
+ FDO_API_COMMON FdoStringP GetString();
+
+protected:
+/// \cond DOXYGEN-IGNORE
+ FdoVectorElement() {}
+ FdoVectorElement( double value )
+ {
+ mValue = value;
+ }
+
+ virtual ~FdoVectorElement(void)
+ {
+ }
+/// \endcond
+
+private:
+ double mValue;
+};
+
+typedef FdoPtr<FdoVectorElement> FdoVectorElementP;
+
+/// \brief
+/// FdoVector is a one-dimensional collection of numbers.
+class FdoVector : public FdoCollection<FdoVectorElement,FdoException>
+{
+public:
+ /// \brief
+ /// Constructs a new empty vector
+ ///
+ /// \return
+ /// Returns FdoVector
+ ///
+ FDO_API_COMMON static FdoVector* Create(void);
+
+ /// \brief
+ /// Creates a copy of a vector
+ ///
+ /// \param src
+ /// Input pointer to the source vector
+ ///
+ /// \return
+ /// Returns FdoVector
+ ///
+ FDO_API_COMMON static FdoVector* Create( const FdoVector* src);
+
+ /// \brief
+ /// Creates a vector that is tokenize from a string.
+ /// The vector contains an element for each token. Non-numberic tokens
+ /// become 0.0.
+ ///
+ /// \param inString
+ /// Input the string to tokenize.
+ /// \param delimiters
+ /// Input list of single character token delimiters.
+ /// \param bNullTokens
+ /// true: include zero-length tokens in the vector ( as 0.0 ).
+ /// false: exclude zero-length tokens
+ ///
+ /// \return
+ /// Returns FdoVector
+ ///
+ FDO_API_COMMON static FdoVector* Create( const FdoStringP& inString, FdoString* delimiters, bool bNullTokens = false );
+
+ /// \brief
+ /// Gets the number in the vector at the specified index. Throws an invalid argument exception if the index is out of range.
+ ///
+ /// \param index
+ /// Input index
+ ///
+ /// \return
+ /// Returns the number in the vector at the specified index
+ ///
+ FDO_API_COMMON double GetValue(int index) const;
+
+ /// \brief
+ /// Appends the numbers from src to the end of this vector.
+ ///
+ /// \param src
+ /// Input the source collection
+ ///
+ FDO_API_COMMON void Append( const FdoVector* src);
+
+ /// \brief
+ /// Adds a number to the end of this vector.
+ ///
+ /// \param value
+ /// Input the source collection
+ ///
+ FDO_API_COMMON int Add( double value );
+
+ /// \brief
+ /// Concatenates the numbers in this collection.
+ ///
+ /// \param separator
+ /// Input separate each collection number with this separator string.
+ ///
+ /// \return
+ /// Returns the concatenation of all numbers in this vector,
+ /// separated by the given separator..
+ ///
+ FDO_API_COMMON FdoStringP ToString( FdoString* separator );
+
+protected:
+/// \cond DOXYGEN-IGNORE
+ FdoVector(void);
+ FdoVector( const FdoVector* src);
+ FdoVector( const FdoStringP& inString, FdoString* delimiters, bool bNullTokens = false );
+
+ virtual ~FdoVector(void);
+/// \endcond
+
+ FDO_API_COMMON virtual void Dispose()
+ {
+ delete this;
+ }
+
+private:
+};
+
+/// \brief
+/// FdoVectorP is a FdoPtr on FdoVector, provided for convenience. It
+/// also provides vector arithmetic and comparison operators.
+class FdoVectorP : public FdoPtr<FdoVector>
+{
+public:
+ /// \brief
+ /// Vector FdoPtr default constructor
+ ///
+ /// \return
+ /// Returns FdoVectorP
+ ///
+ FDO_API_COMMON FdoVectorP() {}
+
+ /// \brief
+ /// Vector FdoPtr copy constructor
+ ///
+ /// \param src
+ /// Input the source vector as a FdoPtr
+ ///
+ /// \return
+ /// Returns FdoVectorP
+ ///
+ FDO_API_COMMON FdoVectorP( const FdoVectorP& src )
+ : FdoPtr<FdoVector>(src)
+ {}
+
+ /// \brief
+ /// Vector FdoPtr copy constructor
+ ///
+ /// \param src
+ /// Input the source vector as an object pointer
+ ///
+ /// \return
+ /// Returns FdoVectorP
+ ///
+ FDO_API_COMMON FdoVectorP( FdoVector* src )
+ : FdoPtr<FdoVector>(src)
+ {}
+
+ /// \brief
+ /// Vector FdoPtr destructor
+ ///
+ FDO_API_COMMON ~FdoVectorP() {}
+
+ /// \brief
+ /// Copies a vector
+ ///
+ /// \param src
+ /// Input the source vector
+ ///
+ /// \return
+ /// Returns a new copy of the input vector
+ ///
+ FDO_API_COMMON FdoVector* operator=( FdoVector* src );
+
+ /// \brief
+ /// Adds two vectors, by adding each individual element. The output vector has
+ /// the same length as the longer of the input vectors. If one input
+ /// vector is shorter than the other, it is treated as if it
+ /// is padded with zeros.
+ ///
+ /// \param vec2
+ /// Input vector to add to this vector
+ ///
+ /// \return
+ /// Returns the sum of the two input vectors
+ ///
+ FDO_API_COMMON const FdoVectorP operator+( const FdoVectorP vec2 ) const;
+
+ /// \brief
+ /// Subtracts two vectors, by subtracting each individual element. The output vector has
+ /// the same length as the longer of the input vectors. If one input
+ /// vector is shorter than the other, it is treated as if it
+ /// is padded with zeros.
+ ///
+ /// \param vec2
+ /// Input vector to subtract from this vector
+ ///
+ /// \return
+ /// Returns the difference of the two input vectors
+ ///
+ FDO_API_COMMON const FdoVectorP operator-( const FdoVectorP vec2 ) const;
+
+ /// \brief
+ /// Adds a vector, to this vector, by adding each individual element. The output vector has
+ /// the same length as the longer of the input vectors. If one input
+ /// vector is shorter than the other, it is treated as if it
+ /// is padded with zeros.
+ ///
+ /// \param vec2
+ /// Input vector to add to this vector
+ ///
+ /// \return
+ /// Returns the sum of the two input vectors
+ ///
+ FDO_API_COMMON FdoVectorP operator+=( const FdoVectorP vec2 );
+
+ /// \brief
+ /// Subtracts a vector, from this vector, by subtracting each individual element. The output vector has
+ /// the same length as the longer of the input vectors. If one input
+ /// vector is shorter than the other, it is treated as if it
+ /// is padded with zeros.
+ ///
+ /// \param vec2
+ /// Input vector to subtract from this vector
+ ///
+ /// \return
+ /// Returns the difference of the two input vectors
+ ///
+ FDO_API_COMMON FdoVectorP operator-=( const FdoVectorP vec2 );
+
+ /// \brief
+ /// Compare two vectors for equality. The vectors are equal
+ /// if all of their elements are equal. If one vector is shorter than the other
+ /// then it is treated as if it were padded with zeros to the length of the
+ /// other vector.
+ ///
+ /// \param vec2
+ /// Input vector to compare this vector
+ ///
+ /// \return
+ /// Returns true if the two vectors are identical.
+ ///
+ FDO_API_COMMON FdoBoolean operator==( const FdoVectorP vec2 ) const;
+
+ /// \brief
+ /// Compare two vectors for difference. The vectors are differnt
+ /// if one of their elements is differnt. If one vector is shorter than the other
+ /// then it is treated as if it were padded with zeros to the length of the
+ /// other vector.
+ ///
+ /// \param vec2
+ /// Input vector to compare this vector
+ ///
+ /// \return
+ /// Returns true if the two vectors are different.
+ ///
+ FDO_API_COMMON FdoBoolean operator!=( const FdoVectorP vec2 ) const;
+
+ /// \brief
+ /// Checks if this vector is greater than a second vector.
+ /// Comparison is done by comparing the first element in each vector.
+ /// If they are equal, then the second element is check and so on until
+ /// a differing element is found. If one vector is shorter than the other
+ /// then it is treated as if it were padded with zeros to the length of the
+ /// other vector.
+ ///
+ /// \param vec2
+ /// Input vector to compare this vector
+ ///
+ /// \return
+ /// Returns true if this vector is greater than vec2.
+ ///
+ FDO_API_COMMON FdoBoolean operator>( const FdoVectorP vec2 ) const;
+
+ /// \brief
+ /// Checks if this vector is greater or equal to a second vector.
+ /// Comparison is done by comparing the first element in each vector.
+ /// If they are equal, then the second element is check and so on until
+ /// a differing element is found. If one vector is shorter than the other
+ /// then it is treated as if it were padded with zeros to the length of the
+ /// other vector.
+ ///
+ /// \param vec2
+ /// Input vector to compare this vector
+ ///
+ /// \return
+ /// Returns true if this vector is greater or equal vec2.
+ ///
+ FDO_API_COMMON FdoBoolean operator>=( const FdoVectorP vec2 ) const;
+
+ /// \brief
+ /// Checks if this vector is less than a second vector.
+ /// Comparison is done by comparing the first element in each vector.
+ /// If they are equal, then the second element is check and so on until
+ /// a differing element is found. If one vector is shorter than the other
+ /// then it is treated as if it were padded with zeros to the length of the
+ /// other vector.
+ ///
+ /// \param vec2
+ /// Input vector to compare this vector
+ ///
+ /// \return
+ /// Returns true if this vector is less than vec2.
+ ///
+ FDO_API_COMMON FdoBoolean operator<( const FdoVectorP vec2 ) const;
+
+ /// \brief
+ /// Checks if this vector is less than or equal to a second vector.
+ /// Comparison is done by comparing the first element in each vector.
+ /// If they are equal, then the second element is check and so on until
+ /// a differing element is found. If one vector is shorter than the other
+ /// then it is treated as if it were padded with zeros to the length of the
+ /// other vector.
+ ///
+ /// \param vec2
+ /// Input vector to compare this vector
+ ///
+ /// \return
+ /// Returns true if this vector is less than or equal vec2.
+ ///
+ FDO_API_COMMON FdoBoolean operator<=( const FdoVectorP vec2 ) const;
+
+/// \cond DOXYGEN-IGNORE
+protected:
+ /// General function to do the vector comparisons.
+ FdoBoolean Compare( const FdoVectorP vec2, FdoBoolean lt, FdoBoolean eq, FdoBoolean gt ) const;
+/// \endcond
+};
+
+#endif
+
+
Modified: trunk/Fdo/Python/Inc/stdafx.h
===================================================================
--- trunk/Fdo/Python/Inc/stdafx.h 2007-03-19 19:47:09 UTC (rev 2695)
+++ trunk/Fdo/Python/Inc/stdafx.h 2007-03-19 23:59:49 UTC (rev 2696)
@@ -20,24 +20,13 @@
// are changed infrequently
//
-#pragma once
+#ifdef WIN32
+#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-
-#include <string.h>
#include <windows.h>
-#include <stdio.h>
-//#if defined(_DEBUG)
-//#define _DEBUG_WAS_DEFINED
-//#undef _DEBUG
-//#pragma message ("Compiling Python header files in Release mode.")
-//#endif
+#endif
-//#include <Python.h>
-
-//#ifdef _DEBUG_WAS_DEFINED
-//#define _DEBUG
-//#undef _DEBUG_WAS_DEFINED
-//#endif
-
+#include <string.h>
+#include <stdio.h>
Modified: trunk/Fdo/Python/Src/Common/StringBuffer.cpp
===================================================================
--- trunk/Fdo/Python/Src/Common/StringBuffer.cpp 2007-03-19 19:47:09 UTC (rev 2695)
+++ trunk/Fdo/Python/Src/Common/StringBuffer.cpp 2007-03-19 23:59:49 UTC (rev 2696)
@@ -33,7 +33,11 @@
{
m_lCapacity = (long)wcslen(str) * 2;
m_pBuffer = this->createEmptyBuffer( m_lCapacity );
- wcscpy_s(m_pBuffer, m_lCapacity, str);
+#ifdef WIN32
+ wcscpy_s(m_pBuffer, m_lCapacity, str);
+#else
+ wcscpy(m_pBuffer, str);
+#endif
}
StringBuffer::StringBuffer( unsigned long initCapacity )
More information about the fdo-commits
mailing list