[mapguide-commits] r1193 - in trunk/MgDev/Common: MdfModel MdfParser

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Mar 9 18:36:57 EST 2007


Author: ronnielouie
Date: 2007-03-09 18:36:56 -0500 (Fri, 09 Mar 2007)
New Revision: 1193

Added:
   trunk/MgDev/Common/MdfModel/Version.cpp
   trunk/MgDev/Common/MdfModel/Version.h
Modified:
   trunk/MgDev/Common/MdfModel/Makefile.am
   trunk/MgDev/Common/MdfModel/MdfModel.vcproj
   trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.cpp
   trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.h
   trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.cpp
   trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.h
   trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp
   trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.h
   trunk/MgDev/Common/MdfParser/SAX2Parser.cpp
   trunk/MgDev/Common/MdfParser/SAX2Parser.h
Log:
Add support for specifying a previous version when writing the layer definition.

Modified: trunk/MgDev/Common/MdfModel/Makefile.am
===================================================================
--- trunk/MgDev/Common/MdfModel/Makefile.am	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfModel/Makefile.am	2007-03-09 23:36:56 UTC (rev 1193)
@@ -79,6 +79,7 @@
   Vector.cpp \
   VectorLayerDefinition.cpp \
   VectorScaleRange.cpp \
+  Version.cpp \
   W2DSymbol.cpp
 
 noinst_HEADERS = \
@@ -164,6 +165,7 @@
   Vector.h \
   VectorLayerDefinition.h \
   VectorScaleRange.h \
+  Version.h \
   W2DSymbol.h \
   stdafx.h
 

Modified: trunk/MgDev/Common/MdfModel/MdfModel.vcproj
===================================================================
--- trunk/MgDev/Common/MdfModel/MdfModel.vcproj	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfModel/MdfModel.vcproj	2007-03-09 23:36:56 UTC (rev 1193)
@@ -874,6 +874,14 @@
 			RelativePath=".\UnicodeString.h"
 			>
 		</File>
+		<File
+			RelativePath=".\Version.cpp"
+			>
+		</File>
+		<File
+			RelativePath=".\Version.h"
+			>
+		</File>
 	</Files>
 	<Globals>
 	</Globals>

Added: trunk/MgDev/Common/MdfModel/Version.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/Version.cpp	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/Version.cpp	2007-03-09 23:36:56 UTC (rev 1193)
@@ -0,0 +1,148 @@
+//
+//  Copyright (C) 2004-2007 by 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
+//
+
+//-------------------------------------------------------------------------
+// DESCRIPTION:
+// Version Class implementation.
+//-------------------------------------------------------------------------
+
+#include "stdafx.h"
+#include "Version.h"
+#include <sstream>
+
+using namespace MDFMODEL_NAMESPACE;
+
+//-------------------------------------------------------------------------
+// PURPOSE: Initialize an instance of the Version class.
+//-------------------------------------------------------------------------
+Version::Version()
+{
+    this->SetMajor(0);
+    this->SetMinor(0);
+    this->SetRevision(0);
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Initialize an instance of the Version class.
+//-------------------------------------------------------------------------
+Version::Version(int nMajorNumber, int nMinorNumber, int nRevisionNumber)
+{
+    this->SetMajor(nMajorNumber);
+    this->SetMinor(nMinorNumber);
+    this->SetRevision(nRevisionNumber);
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Destructor.
+//-------------------------------------------------------------------------
+Version::~Version()
+{
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the Major number.
+// RETURNS: the Major number .
+//-------------------------------------------------------------------------
+int Version::GetMajor()const
+{
+    return this->m_nMajorNumber;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the Major number.
+// PARAMETERS:
+//      Input:
+//          nMajorNumber - the Major number.
+//-------------------------------------------------------------------------
+void Version::SetMajor(const int& nMajorNumber)
+{
+    this->m_nMajorNumber= nMajorNumber;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the Minor number.
+// RETURNS: the Minor number .
+//-------------------------------------------------------------------------
+int Version::GetMinor()const
+{
+    return this->m_nMinorNumber;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the Minor number.
+// PARAMETERS:
+//      Input:
+//          nMinorNumber - the Minor number.
+//-------------------------------------------------------------------------
+void Version::SetMinor(const int& nMinorNumber)
+{
+    this->m_nMinorNumber= nMinorNumber;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the Revision number.
+// RETURNS: the Revision number .
+//-------------------------------------------------------------------------
+int Version::GetRevision()const
+{
+    return this->m_nRevisionNumber;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Accessor method for the Revision number.
+// PARAMETERS:
+//      Input:
+//          nRevisionNumber - the Revision number.
+//-------------------------------------------------------------------------
+void Version::SetRevision(const int& nRevisionNumber)
+{
+    this->m_nRevisionNumber= nRevisionNumber;
+}
+
+//-------------------------------------------------------------------------
+// PURPOSE: Return a string representation of the version.  The format
+//                 is Major.Minor.Revision (ie 1.0.2).
+// RETURNS: the string representation of of the version.
+//-------------------------------------------------------------------------
+MdfString Version::ToString()
+{
+    MdfString strVersion;
+
+    std::wstringstream ss;
+    MdfString strMajor;
+    MdfString strMinor;
+    MdfString strRevision;
+    MdfString strDot = L"."; // NOXLATE
+
+    ss << this->m_nMajorNumber;
+    ss >> strMajor;
+    
+    ss.clear();
+
+    ss << this->m_nMinorNumber;
+    ss >> strMinor;
+
+    ss.clear();
+
+    ss << this->m_nRevisionNumber;
+    ss >> strRevision;
+
+    strVersion = strMajor + strDot + strMinor + strDot + strRevision;
+
+    return strVersion;
+}
+

Added: trunk/MgDev/Common/MdfModel/Version.h
===================================================================
--- trunk/MgDev/Common/MdfModel/Version.h	                        (rev 0)
+++ trunk/MgDev/Common/MdfModel/Version.h	2007-03-09 23:36:56 UTC (rev 1193)
@@ -0,0 +1,69 @@
+//
+//  Copyright (C) 2004-2007 by 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
+//
+
+#ifndef VERSION_H_
+#define VERSION_H_
+
+#include "MdfModel.h"
+#include "MdfRootObject.h"
+
+BEGIN_NAMESPACE_MDFMODEL
+
+    //-------------------------------------------------------------------------
+    // DESCRIPTION:
+    // Represents a version object. 
+    // The format of the version is Major.Minor.Revision.
+    // For example version 1.0.2, 
+    // the Major number is 1, Minor number is 0, Revision number is 2.
+    //-------------------------------------------------------------------------
+    class MDFMODEL_API Version : public MdfRootObject
+    {
+    public:
+        // Construction, destruction, initialization
+        Version();
+        Version(int nMajorNumber, int nMinorNumber, int nRevisionNumber);
+        virtual ~Version();
+
+        // Operations
+        // Property : Major
+        int GetMajor()const;
+        void SetMajor( const int& nMajorNumber);
+
+        // Property : Minor
+        int GetMinor()const;
+        void SetMinor( const int& nMinorNumber);
+
+        // Property : Revision
+        int GetRevision()const;
+        void SetRevision( const int& nRevisionNumber);
+
+        MdfString ToString();
+
+    private:
+        // Data members
+        // The major number in the version
+        int m_nMajorNumber;
+
+        // The minor number in the version
+        int m_nMinorNumber;
+
+        // The revision number in the version
+        int m_nRevisionNumber;
+    };
+
+END_NAMESPACE_MDFMODEL
+#endif //VERSION_H_

Modified: trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.cpp	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.cpp	2007-03-09 23:36:56 UTC (rev 1193)
@@ -96,9 +96,17 @@
     }
 }
 
-void IODrawingLayerDefinition::Write(MdfStream &fd, DrawingLayerDefinition *drawingLayer)
+void IODrawingLayerDefinition::Write(MdfStream &fd, DrawingLayerDefinition *drawingLayer, Version *version)
 {
-    fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-1.1.0.xsd\" version=\"1.1.0\">" << std::endl; // NOXLATE
+    if (version)
+    {
+        MdfString strVersion = version->ToString();
+        fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
+    }
+    else
+    {
+        fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-1.1.0.xsd\" version=\"1.1.0\">" << std::endl; // NOXLATE
+    }
     inctab();
 
     fd << tab() << "<DrawingLayerDefinition>" << std::endl; // NOXLATE

Modified: trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.h	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfParser/IODrawingLayerDefinition.h	2007-03-09 23:36:56 UTC (rev 1193)
@@ -20,6 +20,7 @@
 
 #include "SAX2ElementHandler.h"
 #include "DrawingLayerDefinition.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -35,7 +36,7 @@
         IODrawingLayerDefinition();
         IODrawingLayerDefinition(DrawingLayerDefinition * layer);
         ~IODrawingLayerDefinition();
-        void Write(MdfStream &fd, DrawingLayerDefinition *drawingLayer);
+        void Write(MdfStream &fd, DrawingLayerDefinition *drawingLayer, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.cpp	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.cpp	2007-03-09 23:36:56 UTC (rev 1193)
@@ -100,9 +100,17 @@
     }
 }
 
-void IOGridLayerDefinition::Write(MdfStream &fd, GridLayerDefinition *gridLayer)
+void IOGridLayerDefinition::Write(MdfStream &fd, GridLayerDefinition *gridLayer, Version *version)
 {
-    fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-1.1.0.xsd\" version=\"1.1.0\">" << std::endl; // NOXLATE
+    if (version)
+    {
+        MdfString strVersion = version->ToString();
+        fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
+    }
+    else
+    {
+        fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-1.1.0.xsd\" version=\"1.1.0\">" << std::endl; // NOXLATE
+    }
     inctab();
 
     fd << tab() << "<GridLayerDefinition>" << std::endl; // NOXLATE

Modified: trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.h	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfParser/IOGridLayerDefinition.h	2007-03-09 23:36:56 UTC (rev 1193)
@@ -20,6 +20,7 @@
 
 #include "GridLayerDefinition.h"
 #include "SAX2ElementHandler.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -35,7 +36,7 @@
         IOGridLayerDefinition();
         IOGridLayerDefinition(GridLayerDefinition * layer);
         ~IOGridLayerDefinition();
-        void Write(MdfStream &fd,  GridLayerDefinition *gridLayer);
+        void Write(MdfStream &fd,  GridLayerDefinition *gridLayer, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp	2007-03-09 23:36:56 UTC (rev 1193)
@@ -145,9 +145,17 @@
     }
 }
 
-void IOVectorLayerDefinition::Write(MdfStream &fd, VectorLayerDefinition *featureLayer)
+void IOVectorLayerDefinition::Write(MdfStream &fd, VectorLayerDefinition *featureLayer, Version *version)
 {
-    fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-1.1.0.xsd\" version=\"1.1.0\">" << std::endl; // NOXLATE
+    if (version)
+    {
+        MdfString strVersion = version->ToString();
+        fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-" << EncodeString(strVersion) << ".xsd\" version=\"" << EncodeString(strVersion) << "\">" << std::endl; // NOXLATE
+    }
+    else
+    {
+        fd << tab() << "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-1.1.0.xsd\" version=\"1.1.0\">" << std::endl; // NOXLATE
+    }
     inctab();
 
     fd << tab() << startStr(sVectorLayerDefinition) << std::endl;

Modified: trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.h	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.h	2007-03-09 23:36:56 UTC (rev 1193)
@@ -20,6 +20,7 @@
 
 #include "SAX2ElementHandler.h"
 #include "VectorLayerDefinition.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -35,7 +36,7 @@
         IOVectorLayerDefinition();
         IOVectorLayerDefinition(VectorLayerDefinition * layer);
         ~IOVectorLayerDefinition();
-        void Write(MdfStream &fd, VectorLayerDefinition *featureLayer);
+        void Write(MdfStream &fd, VectorLayerDefinition *featureLayer, Version *version = NULL);
 
         virtual void StartElement(const wchar_t *name, HandlerStack *handlerStack);
         virtual void ElementChars(const wchar_t *ch);

Modified: trunk/MgDev/Common/MdfParser/SAX2Parser.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/SAX2Parser.cpp	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfParser/SAX2Parser.cpp	2007-03-09 23:36:56 UTC (rev 1193)
@@ -320,9 +320,13 @@
     return fd.str();
 }
 
-
 std::string SAX2Parser::SerializeToXML(LayerDefinition *pLayer)
 {
+    return SerializeToXML(pLayer, NULL);
+}
+
+std::string SAX2Parser::SerializeToXML(LayerDefinition *pLayer, Version *version)
+{
     MdfStringStream fd;
 
     VectorLayerDefinition *pVectorLayer = dynamic_cast<VectorLayerDefinition*>(pLayer);
@@ -332,17 +336,17 @@
     if (NULL != pVectorLayer)
     {
         std::auto_ptr<IOVectorLayerDefinition> spIO(new IOVectorLayerDefinition());
-        spIO->Write(fd, pVectorLayer);
+        spIO->Write(fd, pVectorLayer, version);
     }
     else if (NULL != pDrawingLayer)
     {
         std::auto_ptr<IODrawingLayerDefinition> spIO(new IODrawingLayerDefinition());
-        spIO->Write(fd, pDrawingLayer);
+        spIO->Write(fd, pDrawingLayer, version);
     }
     else if (NULL != pGridLayer)
     {
         std::auto_ptr<IOGridLayerDefinition> spIO(new IOGridLayerDefinition());
-        spIO->Write(fd, pGridLayer);
+        spIO->Write(fd, pGridLayer, version);
     }
 
     return fd.str();

Modified: trunk/MgDev/Common/MdfParser/SAX2Parser.h
===================================================================
--- trunk/MgDev/Common/MdfParser/SAX2Parser.h	2007-03-09 22:07:42 UTC (rev 1192)
+++ trunk/MgDev/Common/MdfParser/SAX2Parser.h	2007-03-09 23:36:56 UTC (rev 1193)
@@ -34,6 +34,7 @@
 #include <xercesc/framework/MemBufInputSource.hpp>
 #include "IOUtil.h"
 #include "SAX2ElementHandler.h"
+#include "Version.h"
 
 using namespace XERCES_CPP_NAMESPACE;
 using namespace MDFMODEL_NAMESPACE;
@@ -108,6 +109,7 @@
 
         std::string SerializeToXML(MapDefinition *pMap);
         std::string SerializeToXML(LayerDefinition *pLayer);
+        std::string SerializeToXML(LayerDefinition *pLayer, MdfModel::Version *version);
         std::string SerializeToXML(SymbolDefinition *pSymbol);
 
         // there are two modes for retrieving objects created by parsing:



More information about the mapguide-commits mailing list