summaryrefslogtreecommitdiff
path: root/xml2cmp/source/x2cclass
diff options
context:
space:
mode:
Diffstat (limited to 'xml2cmp/source/x2cclass')
-rw-r--r--xml2cmp/source/x2cclass/x2cstl.hxx47
-rw-r--r--xml2cmp/source/x2cclass/xml_cd.hxx85
-rw-r--r--xml2cmp/source/x2cclass/xml_cdff.cxx231
-rw-r--r--xml2cmp/source/x2cclass/xml_cdff.hxx104
-rw-r--r--xml2cmp/source/x2cclass/xml_cdim.cxx183
-rw-r--r--xml2cmp/source/x2cclass/xml_cdim.hxx113
6 files changed, 763 insertions, 0 deletions
diff --git a/xml2cmp/source/x2cclass/x2cstl.hxx b/xml2cmp/source/x2cclass/x2cstl.hxx
new file mode 100644
index 000000000000..472e474b1889
--- /dev/null
+++ b/xml2cmp/source/x2cclass/x2cstl.hxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef UDKSERVICE_X2CSTL_HXX
+#define UDKSERVICE_X2CSTL_HXX
+
+
+#if STLPORT_VERSION < 321
+#include <tools/presys.h>
+#include <vector.h>
+#include <tools/postsys.h>
+#else
+#include <vector>
+#endif // STLPORT_VERSION < 321
+
+#ifdef _USE_NO_NAMERSPACES_
+#define std
+#endif
+
+
+#endif
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cd.hxx b/xml2cmp/source/x2cclass/xml_cd.hxx
new file mode 100644
index 000000000000..ba075c5aa063
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cd.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef UDKSERVICE_XML_CD_HXX
+#define UDKSERVICE_XML_CD_HXX
+
+
+#include <tools/string.hxx>
+#include "x2cstl.hxx"
+
+
+
+/** Represents one Component description from an XML file.
+ DatumOf() is used for tags with only one value.
+ DataOf() is used, if the tag has multiple values or if
+ you don't know.
+**/
+class ComponentDescription
+{
+ public:
+ /** @ATTENTION
+ Because the enum values are used as array indices:
+ tag_None must be the first and have the value "0".
+ tag_MAX must be the last.
+ The enum values must not be assigned numbers.
+ **/
+ enum E_Tag
+ {
+ tag_None = 0,
+ tag_Name,
+ tag_Description,
+ tag_ModuleName,
+ tag_LoaderName,
+ tag_SupportedService,
+ tag_ProjectBuildDependency,
+ tag_RuntimeModuleDependency,
+ tag_ServiceDependency,
+ tag_Language,
+ tag_Status,
+ tag_Type,
+ tag_MAX
+ };
+
+ virtual ~ComponentDescription() {}
+
+ /// @return All values of this tag. An empty vector for wrong indices.
+ virtual const std::vector< ByteString > &
+ DataOf(
+ ComponentDescription::E_Tag
+ i_eTag ) const = 0;
+
+ /// @return The only or the first value of this tag. An empty string for wrong indices.
+ virtual ByteString DatumOf(
+ ComponentDescription::E_Tag
+ i_eTag ) const = 0;
+};
+
+
+#endif
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cdff.cxx b/xml2cmp/source/x2cclass/xml_cdff.cxx
new file mode 100644
index 000000000000..5ce3b5508a2d
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cdff.cxx
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "xml_cdff.hxx"
+
+#include <string.h>
+#include <tools/stream.hxx>
+#include "xml_cdim.hxx"
+#include <ctype.h>
+
+
+typedef ComponentDescriptionImpl::ValueList CdiValueList;
+
+class dyn_buffer
+{
+ public:
+ dyn_buffer() : s(0) {}
+ ~dyn_buffer() { if (s) delete [] s; }
+ operator const char *() const { return s; }
+ char * operator->() { return s; }
+ char & operator[](
+ INT32 ix ) { return s[ix]; }
+ void SetSize(
+ INT32 i_size ) { if (s) delete [] s; s = new char [i_size]; }
+ private:
+ char * s;
+};
+
+
+inline BOOL
+LoadXmlFile( dyn_buffer & o_rBuffer,
+ const UniString & i_sXmlFilePath )
+{
+ BOOL ret = TRUE;
+ SvFileStream aXmlFile;
+
+ aXmlFile.Open(i_sXmlFilePath, STREAM_READ);
+ if (aXmlFile.GetErrorCode() != FSYS_ERR_OK)
+ ret = FALSE;
+ if (ret)
+ {
+ aXmlFile.Seek(STREAM_SEEK_TO_END);
+ INT32 nBufferSize = aXmlFile.Tell();
+ o_rBuffer.SetSize(nBufferSize + 1);
+ o_rBuffer[nBufferSize] = '\0';
+ aXmlFile.Seek(0);
+ if (aXmlFile.Read(o_rBuffer.operator->(), nBufferSize) == 0)
+ ret = FALSE;
+ }
+
+ aXmlFile.Close();
+ return ret;
+}
+
+
+
+CompDescrsFromAnXmlFile::CompDescrsFromAnXmlFile()
+ : dpDescriptions(new std::vector< ComponentDescriptionImpl* >),
+ eStatus(not_yet_parsed)
+{
+ dpDescriptions->reserve(3);
+}
+
+CompDescrsFromAnXmlFile::~CompDescrsFromAnXmlFile()
+{
+ Empty();
+ delete dpDescriptions;
+}
+
+
+BOOL
+CompDescrsFromAnXmlFile::Parse( const UniString & i_sXmlFilePath )
+{
+ dyn_buffer dpBuffer;
+
+ if (! LoadXmlFile(dpBuffer,i_sXmlFilePath) )
+ {
+ eStatus = cant_read_file;
+ return FALSE;
+ }
+
+ const char * pTokenStart = 0;
+ const char * pBufferPosition = dpBuffer;
+ INT32 nTokenLength = 0;
+ BOOL bWithinElement = FALSE;
+
+ CdiValueList * pCurTagData = 0;
+ ByteString sStatusValue; // Used only if a <Status ...> tag is found.
+
+
+ for ( ComponentDescriptionImpl::ParseUntilStartOfDescription(pBufferPosition);
+ pBufferPosition != 0;
+ ComponentDescriptionImpl::ParseUntilStartOfDescription(pBufferPosition) )
+ {
+ ComponentDescriptionImpl * pCurCD = 0;
+ pCurCD = new ComponentDescriptionImpl;
+ dpDescriptions->push_back(pCurCD);
+
+ for ( ; *pBufferPosition != '\0' && pCurCD != 0; )
+ {
+ switch (*pBufferPosition)
+ {
+ case '<' :
+ if (! bWithinElement)
+ {
+ pCurTagData = pCurCD->GetBeginTag(sStatusValue, pBufferPosition);
+ if (pCurTagData != 0)
+ {
+ if (sStatusValue.Len () == 0)
+ {
+ // Start new token:
+ pTokenStart = pBufferPosition;
+ nTokenLength = 0;
+ bWithinElement = TRUE;;
+ }
+ else
+ {
+ // Status tag is already parsed:
+ pCurTagData->push_back(sStatusValue);
+ } // endif (sStatusValue.Length () == 0)
+ }
+ else if ( ComponentDescriptionImpl::CheckEndOfDescription(pBufferPosition) )
+ {
+ pBufferPosition += ComponentDescriptionImpl::DescriptionEndTagSize();
+ pCurCD = 0;
+ }
+ else
+ {
+ eStatus = inconsistent_file;
+ return FALSE;
+ } // endif (pCurTagData != 0) elseif() else
+ }
+ else if ( pCurTagData->MatchesEndTag(pBufferPosition) )
+ {
+ // Finish token:
+ pBufferPosition += pCurTagData->EndTagLength();
+ bWithinElement = FALSE;
+
+ // Remove leading and trailing spaces:
+ while ( isspace(*pTokenStart) )
+ {
+ pTokenStart++;
+ nTokenLength--;
+ }
+ while ( nTokenLength > 0
+ && isspace(pTokenStart[nTokenLength-1]) )
+ {
+ nTokenLength--;
+ }
+ // Add token to tag values list.
+ pCurTagData->push_back(ByteString(pTokenStart,nTokenLength));
+ }
+ else
+ {
+ nTokenLength++;
+ ++pBufferPosition;
+ } // endif (!bWithinElement) else if () else
+ break;
+ default:
+ if (bWithinElement)
+ {
+ ++nTokenLength;
+ }
+ ++pBufferPosition;
+ } // end switch
+ } // end for
+
+ if (bWithinElement)
+ {
+ eStatus = inconsistent_file;
+ return FALSE;
+ }
+ } // end for
+
+ return TRUE;
+}
+
+INT32
+CompDescrsFromAnXmlFile::NrOfDescriptions() const
+{
+ return dpDescriptions->size();
+}
+
+const ComponentDescription &
+CompDescrsFromAnXmlFile::operator[](INT32 i_nIndex) const
+{
+ static const ComponentDescriptionImpl aNullDescr_;
+ return 0 <= i_nIndex && i_nIndex < dpDescriptions->size()
+ ? *(*dpDescriptions)[i_nIndex]
+ : aNullDescr_;
+}
+
+void
+CompDescrsFromAnXmlFile::Empty()
+{
+ for ( std::vector< ComponentDescriptionImpl* >::iterator aIter = dpDescriptions->begin();
+ aIter != dpDescriptions->end();
+ ++aIter )
+ {
+ delete *aIter;
+ }
+ dpDescriptions->erase( dpDescriptions->begin(),
+ dpDescriptions->end() );
+}
+
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cdff.hxx b/xml2cmp/source/x2cclass/xml_cdff.hxx
new file mode 100644
index 000000000000..a2c47ad0bda2
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cdff.hxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef UDKSERVICE_XML_CDFF_HXX
+#define UDKSERVICE_XML_CDFF_HXX
+
+
+#include <tools/string.hxx>
+#include "xml_cd.hxx"
+
+class ComponentDescriptionImpl;
+
+
+/** @descr
+ Is able to parse an XML file with Component descriptions. Gives access
+ to the parsed data.
+
+ Use:
+ CompDescrsFromAnXmlFile aCds;
+ UniString aFilepath(...);
+ if (! aCds.Parse(aFilepath) )
+ {
+ // react on:
+ aCds.Status();
+ }
+
+ With operator[] you get access to ComponentDescriptions
+ on indices 0 to NrOfDescriptions()-1 .
+
+ For further handling see class ComponentDescription
+ in xml_cd.hxx .
+
+ It is possible to parse more than one time. Then the old data
+ are discarded.
+**/
+class CompDescrsFromAnXmlFile
+{
+ public:
+ enum E_Status
+ {
+ ok = 0,
+ not_yet_parsed,
+ cant_read_file,
+ inconsistent_file,
+ no_tag_found_in_file
+ };
+
+ // LIFECYCLE
+ CompDescrsFromAnXmlFile();
+ ~CompDescrsFromAnXmlFile();
+
+ // OPERATIONS
+ BOOL Parse(
+ const UniString & i_sXmlFilePath );
+
+ // INQUIRY
+ INT32 NrOfDescriptions() const;
+ const ComponentDescription &
+ operator[]( /// @return an empty description, if index does not exist.
+ INT32 i_nIndex ) const;
+ CompDescrsFromAnXmlFile::E_Status
+ Status() const;
+
+ private:
+ // PRIVATE SERVICES
+ void Empty();
+
+ // DATA
+ std::vector< ComponentDescriptionImpl* > *
+ dpDescriptions;
+ E_Status eStatus;
+};
+
+
+
+
+
+#endif
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cdim.cxx b/xml2cmp/source/x2cclass/xml_cdim.cxx
new file mode 100644
index 000000000000..05bb0d4741fb
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cdim.cxx
@@ -0,0 +1,183 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "xml_cdim.hxx"
+
+const char ComponentDescriptionImpl::C_sTagDescription[]
+ = "COMPONENTDESCRIPTION";
+const char ComponentDescriptionImpl::C_sStatus[]
+ = "Status";
+const char * ComponentDescriptionImpl::C_sSubTags[ComponentDescription::tag_MAX]
+ = { "None",
+ "Name",
+ "Description",
+ "ModuleName",
+ "LoaderName",
+ "SupportedService",
+ "ProjectBuildDependency",
+ "RuntimeModuleDependency",
+ "ServiceDependency",
+ "Language",
+ C_sStatus,
+ "Type"
+ };
+
+ComponentDescriptionImpl::ComponentDescriptionImpl()
+// : aTags
+{
+ const int i_max = tag_MAX;
+ aTags.reserve(i_max);
+
+ for (int i = 0; i < i_max; ++i)
+ {
+ aTags.push_back( new ValueList(E_Tag(i)) );
+ } // end for
+}
+
+ComponentDescriptionImpl::~ComponentDescriptionImpl()
+{
+ for ( std::vector< ValueList* >::iterator aIter = aTags.begin();
+ aIter != aTags.end();
+ ++aIter )
+ {
+ delete *aIter;
+ }
+}
+
+inline void
+GetStatusValue( ByteString & o_sValue, const ByteString & i_sStatusTag )
+{
+ // o_sValue is always == "" at the beginning.
+
+ const char * pStatusValue = strchr(i_sStatusTag.GetBuffer(), '"');
+ if (pStatusValue == 0)
+ return;
+ pStatusValue++;
+ const char * pStatusValueEnd = strrchr(pStatusValue,'"');
+ if (pStatusValueEnd == 0 || pStatusValueEnd - pStatusValue < 1)
+ return ;
+
+ ByteString sValue(pStatusValue, pStatusValueEnd - pStatusValue);
+ o_sValue = sValue;
+}
+
+ComponentDescriptionImpl::ValueList *
+ComponentDescriptionImpl::GetBeginTag( ByteString & o_sValue,
+ const char *& io_pStartOfTag ) const
+{
+ o_sValue = "";
+
+ const char * pCurTextEnd = strchr(io_pStartOfTag,'>');
+ if ( 0 == pCurTextEnd )
+ return 0;
+
+ if ( ComponentDescriptionImpl::CheckEndOfDescription(io_pStartOfTag) )
+ return 0;
+
+ ByteString sTag(io_pStartOfTag + 1, pCurTextEnd - io_pStartOfTag - 1);
+ io_pStartOfTag += sTag.Len() + 2;
+
+ // Special case <Status ... >
+ if ( strnicmp(C_sStatus, sTag.GetBuffer(), (sizeof C_sStatus) - 1 ) == 0 )
+ {
+ GetStatusValue(o_sValue,sTag);
+ return aTags[tag_Status];
+ }
+
+ // Regular seeking for matching data list:
+ for ( INT32 i = 0; i < tag_MAX; i++ )
+ {
+ if ( 0 == stricmp(sTag.GetBuffer(), C_sSubTags[i]) )
+ return aTags[i];
+ } // end for
+
+ return 0;
+}
+
+const std::vector< ByteString > &
+ComponentDescriptionImpl::DataOf( ComponentDescriptionImpl::E_Tag i_eTag ) const
+{
+ if (0 < i_eTag && i_eTag < tag_MAX)
+ return *aTags[i_eTag];
+ else
+ return ValueList::Null_();
+}
+
+ByteString
+ComponentDescriptionImpl::DatumOf( ComponentDescriptionImpl::E_Tag i_eTag ) const
+{
+ if (0 < i_eTag && i_eTag < tag_MAX)
+ {
+ ValueList & rValues = *aTags[i_eTag];
+ if (rValues.size() > 0)
+ return rValues[0];
+ }
+ return "";
+}
+
+void
+ComponentDescriptionImpl::ParseUntilStartOfDescription( const char * & io_pBufferPosition )
+{
+ for ( const char * pSearch = strchr(io_pBufferPosition,'<');
+ pSearch != 0;
+ pSearch = strchr(pSearch+1,'<') )
+ {
+ if ( pSearch != io_pBufferPosition
+ && 0 == strnicmp(pSearch+1,C_sTagDescription, strlen(C_sTagDescription))
+ && *(pSearch + strlen(C_sTagDescription) + 1) == '>' )
+ {
+ io_pBufferPosition = pSearch + strlen(C_sTagDescription) + 2;
+ return;
+ }
+ } // end for
+
+ io_pBufferPosition = 0;
+}
+
+BOOL
+ComponentDescriptionImpl::ValueList::MatchesEndTag( const char * i_pTextPosition ) const
+{
+ return strnicmp( i_pTextPosition+2, C_sSubTags[eTag], strlen(C_sSubTags[eTag]) ) == 0
+ && strncmp(i_pTextPosition,"</",2) == 0
+ && *(i_pTextPosition + 2 + strlen(C_sSubTags[eTag]) ) == '>';
+}
+
+INT32
+ComponentDescriptionImpl::ValueList::EndTagLength() const
+{
+ return strlen(C_sSubTags[eTag]) + 3;
+}
+
+
+const ComponentDescriptionImpl::ValueList &
+ComponentDescriptionImpl::ValueList::Null_()
+{
+ static const ValueList aNull_(ComponentDescription::tag_None);
+ return aNull_;
+}
+
+
diff --git a/xml2cmp/source/x2cclass/xml_cdim.hxx b/xml2cmp/source/x2cclass/xml_cdim.hxx
new file mode 100644
index 000000000000..cbf611c03e07
--- /dev/null
+++ b/xml2cmp/source/x2cclass/xml_cdim.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef UDKSERVICE_XML_CDIM_HXX
+#define UDKSERVICE_XML_CDIM_HXX
+
+
+#include "xml_cd.hxx"
+#include <tools/string.hxx>
+
+
+
+
+
+/** Represents one of the Component descriptions in an XML file.
+ Implements ComponentDescription and does part of the parsing for class CompDescrsFromAnXmlFile.
+**/
+class ComponentDescriptionImpl : public ComponentDescription
+{
+ public:
+ class ValueList : public std::vector< ByteString >
+ {
+ public:
+ // LIFECYCLE
+ ValueList(
+ E_Tag i_eTag )
+ : eTag(i_eTag) {}
+ // INQUIRY
+ const char * BeginTag() const;
+ BOOL MatchesEndTag(
+ const char * i_pTextPosition ) const;
+ INT32 EndTagLength() const;
+
+ static const ValueList &
+ Null_();
+ private:
+ E_Tag eTag;
+ };
+
+ // LIFECYCLE
+ ComponentDescriptionImpl();
+ virtual ~ComponentDescriptionImpl();
+
+ // OPERATIONS
+ ValueList * GetBeginTag(
+ ByteString & o_sValue,
+ const char * & io_pStartOfTag ) const;
+ static void ParseUntilStartOfDescription(
+ const char * & io_pBufferPosition );
+ static BOOL CheckEndOfDescription(
+ const char * & io_pBufferPosition );
+ // INQUIRY
+ static INT32 DescriptionEndTagSize();
+
+ // INTERFACE ComponentDescription
+ // INQUIRY
+ virtual const std::vector< ByteString > &
+ DataOf( /// @return All values of this tag.
+ ComponentDescription::E_Tag
+ i_eTag ) const;
+ virtual ByteString DatumOf( /// @return The only or the first value of this tag.
+ ComponentDescription::E_Tag
+ i_eTag ) const;
+ private:
+ // DATA
+ static const char C_sTagDescription[];
+ static const char C_sStatus[];
+ static const char * C_sSubTags[ComponentDescription::tag_MAX];
+ friend class ValueList;
+
+ std::vector< ValueList* > // Dynamic allocated pointers.
+ aTags;
+};
+
+
+inline BOOL
+ComponentDescriptionImpl::CheckEndOfDescription( const char * & io_pBufferPosition )
+ { return strnicmp(io_pBufferPosition + 2, C_sTagDescription, strlen(C_sTagDescription)) == 0
+ && strncmp(io_pBufferPosition, "</", 2) == 0
+ && * (io_pBufferPosition + 2 + strlen(C_sTagDescription)) == '>'; }
+
+inline INT32
+ComponentDescriptionImpl::DescriptionEndTagSize()
+ { return strlen(C_sTagDescription) + 3; }
+
+
+#endif
+
+