diff options
author | Nikolai Pretzell <np@openoffice.org> | 2001-03-23 12:24:04 +0000 |
---|---|---|
committer | Nikolai Pretzell <np@openoffice.org> | 2001-03-23 12:24:04 +0000 |
commit | c62b94519dabf91a6766b7e4e822c0e8c20bd738 (patch) | |
tree | 79f02e2f70ada4cb52b33cb596a414290cb59a28 | |
parent | 924738d648fe14454b45ef979d3a05fe42b35e72 (diff) |
Allow tag <type> in module-description
24 files changed, 944 insertions, 919 deletions
diff --git a/xml2cmp/source/support/cmdline.cxx b/xml2cmp/source/support/cmdline.cxx index 2a9145aa8..bd3537af7 100644 --- a/xml2cmp/source/support/cmdline.cxx +++ b/xml2cmp/source/support/cmdline.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cmdline.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/support/cmdline.hxx b/xml2cmp/source/support/cmdline.hxx index 94c67d49f..de7f8d88c 100644 --- a/xml2cmp/source/support/cmdline.hxx +++ b/xml2cmp/source/support/cmdline.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cmdline.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/support/heap.cxx b/xml2cmp/source/support/heap.cxx index 89e8f2250..1ced77de7 100644 --- a/xml2cmp/source/support/heap.cxx +++ b/xml2cmp/source/support/heap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: heap.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/support/heap.hxx b/xml2cmp/source/support/heap.hxx index e56745f4b..a70c2dc74 100644 --- a/xml2cmp/source/support/heap.hxx +++ b/xml2cmp/source/support/heap.hxx @@ -2,9 +2,9 @@ * * $RCSfile: heap.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/support/list.hxx b/xml2cmp/source/support/list.hxx index 7e2de76f9..9e9c7dbb1 100644 --- a/xml2cmp/source/support/list.hxx +++ b/xml2cmp/source/support/list.hxx @@ -2,9 +2,9 @@ * * $RCSfile: list.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/support/makefile.mk b/xml2cmp/source/support/makefile.mk index 2d34106ae..1d4cf5625 100644 --- a/xml2cmp/source/support/makefile.mk +++ b/xml2cmp/source/support/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ +# last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses diff --git a/xml2cmp/source/support/sistr.cxx b/xml2cmp/source/support/sistr.cxx index ff2d9439f..6e680e220 100644 --- a/xml2cmp/source/support/sistr.cxx +++ b/xml2cmp/source/support/sistr.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sistr.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -671,7 +671,7 @@ Simstr::is_no_text() const return true; int i; - for (i = 0; ( sz[i] == ' ' || sz[i] == '\t' ) && i < len; i++); + for (i = 0; sz[i] <= 32 && i < len; i++); if (i < len) return false; return true; diff --git a/xml2cmp/source/support/sistr.hxx b/xml2cmp/source/support/sistr.hxx index c9e20e75f..e273feda1 100644 --- a/xml2cmp/source/support/sistr.hxx +++ b/xml2cmp/source/support/sistr.hxx @@ -2,9 +2,9 @@ * * $RCSfile: sistr.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/support/syshelp.cxx b/xml2cmp/source/support/syshelp.cxx index 346663b31..ffe1a66bc 100644 --- a/xml2cmp/source/support/syshelp.cxx +++ b/xml2cmp/source/support/syshelp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: syshelp.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,13 +66,26 @@ // NOT FULLY DEFINED SERVICES #include <string.h> #include "sistr.hxx" +#include "list.hxx" +#ifdef WNT +#include <io.h> +#elif defined(UNX) +#include <sys/types.h> +#include <sys/stat.h> +#include <dirent.h> +#define stricmp strcasecmp +#else +#error Must run under unix or windows, please define UNX or WNT. +#endif +using namespace std; + char C_sSpaceInName[] = " "; void -WriteName( std::ofstream & o_rFile, +WriteName( ofstream & o_rFile, const Simstr & i_rIdlDocuBaseDir, const Simstr & i_rName, E_LinkType i_eLinkType ) @@ -89,7 +102,7 @@ WriteName( std::ofstream & o_rFile, if ( pNameEnd != 0 ) { const char * pStart = i_rName.str(); - o_rFile.write( pStart, pNameEnd -1 - pStart ); + o_rFile.write( pStart, pNameEnd - pStart ); WriteStr( o_rFile, C_sSpaceInName ); WriteStr( o_rFile, pNameEnd ); } @@ -188,4 +201,151 @@ WriteStr( std::ofstream & o_rFile, { o_rFile.write( i_sStr.str(), i_sStr.l() ); } - + + +const char C_sXML_END[] = "\\*.xml"; + +void +GatherFileNames( List<Simstr> & o_sFiles, + const char * i_sSrcDirectory ) +{ + static int nAliveCounter = 0; + + char * sNextDir = 0; + Simstr sNew = 0; + +#ifdef WNT + struct _finddata_t aEntry; + long hFile = 0; + int bFindMore = 0; + char * sFilter = new char[ strlen(i_sSrcDirectory) + sizeof C_sXML_END ]; + + // Stayingalive sign + if (++nAliveCounter % 100 == 1) + cout << "." << flush; + + strcpy(sFilter, i_sSrcDirectory); + strcat(sFilter,C_sXML_END); + + hFile = _findfirst( sFilter, &aEntry ); + for ( bFindMore = hFile == -1; + bFindMore == 0; + bFindMore = _findnext( hFile, &aEntry ) ) + { + sNew = i_sSrcDirectory; + sNew += "\\"; + sNew += aEntry.name; + o_sFiles.push_back(sNew); + } // end for + + _findclose(hFile); + delete [] sFilter; +#elif defined(UNX) + DIR * pDir = opendir( i_sSrcDirectory ); + dirent * pEntry = 0; + char * sEnding; + + // Stayingalive sign + if (++nAliveCounter % 100 == 1) + cout << "." << flush; + + while ( (pEntry = readdir(pDir)) != 0 ) + { + sEnding = strrchr(pEntry->d_name,'.'); + if (sEnding != 0 ? stricmp(sEnding,".xml") == 0 : 0 ) + { + sNew = i_sSrcDirectory; + sNew += "/"; + sNew += pEntry->d_name; + o_sFiles.push_back(sNew); + } + } // end while + + closedir( pDir ); +#else +#error Must run on unix or windows, please define UNX or WNT. +#endif + + // gathering from subdirectories: + List<Simstr> aSubDirectories; + GatherSubDirectories( aSubDirectories, i_sSrcDirectory ); + + unsigned d_max = aSubDirectories.size(); + for ( unsigned d = 0; d < d_max; ++d ) + { + sNextDir = new char[ strlen(i_sSrcDirectory) + 2 + aSubDirectories[d].l() ]; + + strcpy(sNextDir, i_sSrcDirectory); + strcat(sNextDir, C_sSLASH); + strcat(sNextDir, aSubDirectories[d].str()); + GatherFileNames(o_sFiles, sNextDir); + + delete [] sNextDir; + } +} + + +const char * C_sANYDIR = "\\*.*"; + +void +GatherSubDirectories( List<Simstr> & o_sSubDirectories, + const char * i_sParentdDirectory ) +{ + Simstr sNew; + +#ifdef WNT + struct _finddata_t aEntry; + long hFile = 0; + int bFindMore = 0; + char * sFilter = new char[strlen(i_sParentdDirectory) + sizeof C_sANYDIR]; + + strcpy(sFilter, i_sParentdDirectory); + strcat(sFilter,C_sANYDIR); + + hFile = _findfirst( sFilter, &aEntry ); + for ( bFindMore = hFile == -1; + bFindMore == 0; + bFindMore = _findnext( hFile, &aEntry ) ) + { + if (aEntry.attrib == _A_SUBDIR) + { + // Do not gather . .. and outputtree directories + if ( strchr(aEntry.name,'.') == 0 + && strncmp(aEntry.name, "wnt", 3) != 0 + && strncmp(aEntry.name, "unx", 3) != 0 ) + { + sNew = aEntry.name; + o_sSubDirectories.push_back(sNew); + } + } // endif (aEntry.attrib == _A_SUBDIR) + } // end for + _findclose(hFile); + delete [] sFilter; + +#elif defined(UNX) + DIR * pDir = opendir( i_sParentdDirectory ); + dirent * pEntry = 0; + struct stat aEntryStatus; + char * sEnding; + + while ( ( pEntry = readdir(pDir) ) != 0 ) + { + stat(pEntry->d_name, &aEntryStatus); + if ( ( aEntryStatus.st_mode & S_IFDIR ) == S_IFDIR ) + { + // Do not gather . .. and outputtree directories + if ( strchr(pEntry->d_name,'.') == 0 + && strncmp(pEntry->d_name, "wnt", 3) != 0 + && strncmp(pEntry->d_name, "unx", 3) != 0 ) + { + sNew = pEntry->d_name; + o_sSubDirectories.push_back(sNew); + } + } // endif (aEntry.attrib == _A_SUBDIR) + } // end while + closedir( pDir ); +#else +#error Must run on unix or windows, please define UNX or WNT. +#endif +} + diff --git a/xml2cmp/source/support/syshelp.hxx b/xml2cmp/source/support/syshelp.hxx index 65fd7c26d..b4b3f60b8 100644 --- a/xml2cmp/source/support/syshelp.hxx +++ b/xml2cmp/source/support/syshelp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: syshelp.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:51 $ + * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,7 +71,7 @@ #include <fstream> class Simstr; - +template <class XY> class List; #ifdef WNT @@ -106,6 +106,14 @@ void WriteStr( std::ofstream & o_rFile, const Simstr & i_sStr ); +void GatherFileNames( + List<Simstr> & o_sFiles, + const char * i_sSrcDirectory ); +void GatherSubDirectories( + List<Simstr> & o_sSubDirectories, + const char * i_sParentdDirectory ); + + #endif diff --git a/xml2cmp/source/xcd/cr_html.cxx b/xml2cmp/source/xcd/cr_html.cxx index 824da2242..210e47c3b 100644 --- a/xml2cmp/source/xcd/cr_html.cxx +++ b/xml2cmp/source/xcd/cr_html.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cr_html.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,14 +87,14 @@ char C_sHtmlFileFoot[] = "</BODY>\n</HTML>\n"; HtmlCreator::HtmlCreator( const char * i_pOutputFileName, - const ModuleDescription & i_rDescr, + const XmlElement & i_rDocument, const Simstr & i_sIDL_BaseDirectory ) : aFile(i_pOutputFileName, ios::out #ifdef WNT | ios::binary #endif ), - rDescr(i_rDescr), + rDocument(i_rDocument), sIdl_BaseDirectory(i_sIDL_BaseDirectory) { if ( !aFile ) @@ -116,133 +116,151 @@ HtmlCreator::Run() WriteStr( "ModuleDescription" ); WriteStr( C_sHtmlFileHeader2 ); - StartTable(); + rDocument.Write2Html(*this); - const ParentElement::ChildList & rModuleElements = rDescr.Children(); - unsigned i_max = rModuleElements.size(); + WriteStr( "<P><BR><BR></P>\n" ); + WriteStr( C_sHtmlFileFoot ); +} - for (unsigned i = 0; i < i_max; i++) - { - Write_TextElement( *rModuleElements[i], lt_nolink ); // Name, - // ProjectBuildDependency, - // RuntimeModuleDependency - } // end for +void +HtmlCreator::StartTable() +{ + WriteStr( "<P><BR></P>\n" ); + WriteStr( + "<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 CELLPADDING=4>\n" + " <TBODY>\n" ); +} - WriteStr( "<TR><TD COLSPAN=2>\n" - "<H4><BR>Components</H4>\n" ); +void +HtmlCreator::FinishTable() +{ + WriteStr( " </TBODY>\n" + "</TABLE>\n\n" ); +} - const ModuleDescription::CD_List & rCDs = rDescr.Components(); - unsigned d_max = rCDs.size(); - for (unsigned d = 0; d < d_max; d++) - { - WriteStr( "<P><BR><BR></P>\n" ); +void +HtmlCreator::StartBigCell( const char * i_sTitle ) +{ + WriteStr( "<TR><TD COLSPAN=2>\n" + "<H4><BR>" ); + WriteStr( i_sTitle ); + WriteStr( "</H4>\n" ); - Write_Description( *rCDs[d] ); - } // end for +} +void +HtmlCreator::FinishBigCell() +{ WriteStr( "</TD><TR>\n" ); - FinishTable(); - - WriteStr( "<P><BR><BR></P>\n" ); - WriteStr( C_sHtmlFileFoot ); } - void -HtmlCreator::Write_Description( const ComponentDescription & i_rDescr ) +HtmlCreator::Write_SglTextElement( const SglTextElement & i_rElement, + bool i_bStrong ) { - StartTable(); + StartRow(); - const ParentElement::ChildList & rDescrElements = i_rDescr.Children(); + WriteElementName( i_rElement.Name(), i_bStrong ); - unsigned i_max = rDescrElements.size(); - Write_TextElement( *rDescrElements[0], lt_nolink ); // Name - Write_TextElement( *rDescrElements[1], lt_nolink ); // Author - Write_TextElement( *rDescrElements[2], lt_nolink ); // Description - Write_TextElement( *rDescrElements[3], lt_idl ); // Loader Name - Write_TextElement( *rDescrElements[4], lt_nolink ); // Language + StartCell( "77%"); + if (i_bStrong) + { + WriteStr( "<H4><A NAME=\"" ); + unsigned nLen = strlen(i_rElement.Data()); + if ( i_rElement.IsReversedName()) + { + const char * pEnd = strchr(i_rElement.Data(), ' '); + nLen = pEnd - i_rElement.Data(); + } + aFile.write( i_rElement.Data(), nLen ); + WriteStr( "\">" ); + } - Write_Status(i_rDescr.Status()); // Status + WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(), + i_bStrong ? lt_nolink : i_rElement.LinkType() ); - for (unsigned i = 5; i < i_max; i++) - { - Write_TextElement( *rDescrElements[i], lt_idl ); // Supported Service, - // Service Dependency, - // Type + if (i_bStrong) + WriteStr( "</A></H4>" ); + FinishCell(); - } // end for + FinishRow(); +} + +void +HtmlCreator::Write_MultiTextElement( const MultipleTextElement & i_rElement ) +{ + StartRow(); + + WriteElementName( i_rElement.Name(), false ); - const ComponentDescription::Docu_List & rDocuRefs = i_rDescr.DocuRefs(); - unsigned r_max = rDocuRefs.size(); - for (unsigned r = 0; r < r_max; r++) + StartCell( "77%"); + unsigned i_max = i_rElement.Size(); + for ( unsigned i = 0; i < i_max; ++i ) { - Write_ReferenceDocu(*rDocuRefs[r]); - } // end for + if (i > 0) + WriteStr( "<BR>\n" ); + WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(i), i_rElement.LinkType() ); + } // end for + FinishCell(); - FinishTable(); + FinishRow(); } void -HtmlCreator::Write_TextElement( TextElement & i_rElement, - E_LinkType i_eLinkType ) +HtmlCreator::Write_SglText( const Simstr & i_sName, + const Simstr & i_sValue ) { StartRow(); - WriteElementName( i_rElement ); - WriteElementData( i_rElement, i_eLinkType ); + WriteElementName( i_sName, false ); + + StartCell( "77%"); + WriteStr( i_sValue ); + FinishCell(); FinishRow(); } void -HtmlCreator::Write_ReferenceDocu( const ReferenceDocuElement & i_rRefDocu ) +HtmlCreator::Write_ReferenceDocu( const Simstr & i_sName, + const Simstr & i_sRef, + const Simstr & i_sRole, + const Simstr & i_sTitle ) { StartRow(); StartCell( "23%" ); - WriteStr("ReferenceDocu"); + WriteStr(i_sName); FinishCell(); StartCell( "77%" ); - if ( i_rRefDocu.sAttr_href.l() > 0) + if ( !i_sRef.is_empty() ) { - WriteStr("<A href=\"http://"); - WriteStr(i_rRefDocu.sAttr_href.str()); + WriteStr("<A href=\""); + WriteStr(i_sRef); WriteStr("\">"); - WriteStr(i_rRefDocu.sAttr_href.str()); + if ( !i_sTitle.is_empty() ) + WriteStr( i_sTitle ); + else + WriteStr(i_sRef); WriteStr("</A><BR>\n"); } - if ( i_rRefDocu.sAttr_title.l() > 0) + else if ( !i_sTitle.is_empty() ) { WriteStr("Title: "); - WriteStr(i_rRefDocu.sAttr_title.str()); + WriteStr( i_sTitle ); WriteStr("<BR>\n"); } - if ( i_rRefDocu.sAttr_role.l() > 0) + if ( !i_sRole.is_empty() ) { WriteStr("Role: "); - WriteStr(i_rRefDocu.sAttr_role.str()); + WriteStr( i_sRole ); } FinishCell(); FinishRow(); } -void -HtmlCreator::Write_Status(const char * i_sStatus) -{ - StartRow(); - - StartCell( "23%" ); - WriteStr("status"); - FinishCell(); - - StartCell( "77%"); - WriteName( aFile, sIdl_BaseDirectory, i_sStatus, lt_nolink ); - FinishCell(); - - FinishRow(); -} void HtmlCreator::PrintH1( char * i_pText) @@ -255,21 +273,6 @@ HtmlCreator::PrintH1( char * i_pText) } void -HtmlCreator::StartTable() -{ - WriteStr( - "<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 CELLPADDING=4>\n" - " <TBODY>\n" ); -} - -void -HtmlCreator::FinishTable() -{ - WriteStr( " </TBODY>\n" - "</TABLE>\n\n" ); -} - -void HtmlCreator::StartRow() { WriteStr( " <TR VALIGN=TOP>\n" ); @@ -296,62 +299,17 @@ HtmlCreator::FinishCell() } void -HtmlCreator::WriteElementName( TextElement & i_rElement ) +HtmlCreator::WriteElementName( const Simstr & i_sName, + bool i_bStrong ) { StartCell( "23%" ); - const char * pName = i_rElement.Name(); - bool bStrong = strcmp(pName,"name") == 0 || strcmp(pName,"module-name") == 0; - - if (bStrong) + if (i_bStrong) WriteStr( "<H4>" ); - WriteStr(pName); - if (bStrong) + WriteStr(i_sName); + if (i_bStrong) WriteStr( "</H4>" ); FinishCell(); } -void -HtmlCreator::WriteElementData( TextElement & i_rElement, - E_LinkType i_eLinkType ) -{ - StartCell( "77%"); - - bool bStrong = strcmp(i_rElement.Name(),"name") == 0 || strcmp(i_rElement.Name(),"module-name") == 0; - - if (bStrong) - { - WriteStr( "<H4><A NAME=\"" ); - int nLen = strlen(i_rElement.Data()); - if ( *i_rElement.Name() == 'n') - { - const char * pEnd = strchr(i_rElement.Data(), ' '); - if (pEnd) - { - nLen = pEnd - i_rElement.Data(); - } - } - aFile.write( i_rElement.Data(), nLen ); - WriteStr( "\">" ); - } - - WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(), i_eLinkType ); - - if (bStrong) - WriteStr( "</A></H4>" ); - - - unsigned i_max = i_rElement.Size(); - if ( i_max > 1 ) - { - for ( unsigned i = 1; i < i_max; ++i ) - { - WriteStr( "<BR>\n" ); - WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(i), i_eLinkType ); - } // end for - } // end if - - FinishCell(); -} - diff --git a/xml2cmp/source/xcd/cr_html.hxx b/xml2cmp/source/xcd/cr_html.hxx index 816039666..217e40f81 100644 --- a/xml2cmp/source/xcd/cr_html.hxx +++ b/xml2cmp/source/xcd/cr_html.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cr_html.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,10 +69,9 @@ #include "../support/syshelp.hxx" -class ModuleDescription; -class ComponentDescription; -class TextElement; -class ReferenceDocuElement; +class XmlElement; +class SglTextElement; +class MultipleTextElement; class HtmlCreator @@ -80,49 +79,51 @@ class HtmlCreator public: HtmlCreator( const char * i_pOutputFileName, - const ModuleDescription & - i_rDescr, + const XmlElement & i_rDocument, const Simstr & i_sIDL_BaseDirectory ); ~HtmlCreator(); void Run(); + void StartTable(); + void FinishTable(); + void StartBigCell( + const char * i_sTitle ); + void FinishBigCell(); + + void Write_SglTextElement( + const SglTextElement & + i_rElement, + bool i_bStrong = false ); + void Write_MultiTextElement( + const MultipleTextElement & + i_rElement ); + void Write_SglText( + const Simstr & i_sName, + const Simstr & i_sValue ); + void Write_ReferenceDocu( + const Simstr & i_sName, + const Simstr & i_sRef, + const Simstr & i_sRole, + const Simstr & i_sTitle ); private: void PrintH1( char * i_pText ); - void StartTable(); - void FinishTable(); void StartRow(); void FinishRow(); void StartCell( char * i_pWidth ); void FinishCell(); - - void Write_Description( - const ComponentDescription & - i_rDescr ); - void Write_TextElement( - TextElement & i_rElement, - E_LinkType i_eLinkType ); - void Write_ReferenceDocu( - const ReferenceDocuElement & - i_rRefDocu ); - void Write_Status( - const char * i_sStatus ); void WriteElementName( - TextElement & i_rElement ); - void WriteElementData( - TextElement & i_rElement, - E_LinkType i_eLinkType ); - + const Simstr & i_sName, + bool i_bStrong ); void WriteStr( const char * i_sStr ) { aFile.write( i_sStr, strlen(i_sStr) ); } // DATA ofstream aFile; - const ModuleDescription & - rDescr; + const XmlElement & rDocument; Simstr sIdl_BaseDirectory; }; diff --git a/xml2cmp/source/xcd/cr_index.cxx b/xml2cmp/source/xcd/cr_index.cxx index 46cd8c7e6..f2382e898 100644 --- a/xml2cmp/source/xcd/cr_index.cxx +++ b/xml2cmp/source/xcd/cr_index.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cr_index.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -72,6 +72,7 @@ using std::cerr; using std::ofstream; +extern unsigned C_nSupportedServicesIndex; char C_sLineEnd[] = "\n"; @@ -84,83 +85,26 @@ char C_sModule[] = "ModuleName"; char C_sComponentname[] = "ComponentName"; -int NrOfTagName(const char * i_sName); - Simstr sIdlRootPath; -void WriteTableFromHeap( - ofstream & o_rOut, - Heap & i_rHeap, - const char * i_sIndexKey, - const char * i_sIndexReference, - E_LinkType i_eLinkType ); -void WriteHeap( - ofstream & o_rOut, - Heap & i_rHeap, - E_LinkType i_eLinkType ); - Index::Index( const char * i_sOutputDirectory, const char * i_sIdlRootPath, const List<Simstr> & i_rTagList ) : aService2Module(20), aModule2Service(20), - aTagIndices(i_rTagList), sOutputDirectory(i_sOutputDirectory), sIdlRootPath(i_sIdlRootPath) + // sCurModule { ::sIdlRootPath = i_sIdlRootPath; } -Index::IndexedTags::IndexedTags( const List<Simstr> & i_rTagList ) - : nSize(i_rTagList.size()) -{ - aTagHeaps.reserve(nSize); - aTagNames.reserve(nSize); - - for (int h = 0; h < C_nNrOfTagNames; ++h ) - { - aHeapsPerIndex[h] = 0; - } - - for ( unsigned i = 0; i < nSize; ++i ) - { - int nNr = NrOfTagName(i_rTagList[i]); - if ( nNr > -1 ) - { - Heap * pNew = new Heap(20); - aTagHeaps.push_back( pNew ); - aTagNames.push_back( i_rTagList[i] ); - aHeapsPerIndex[nNr] = pNew; - } - else - { - cerr << "Warning: It is not possible to create an index for the tag " - << i_rTagList[i] - << "." - << std::endl; - } - } // end for -} - Index::~Index() { } -Index::IndexedTags::~IndexedTags() -{ -} - -Heap * -Index::IndexedTags::HeapFor( const char * i_sTagName ) -{ - int nNr = NrOfTagName(i_sTagName); - if (nNr > -1 ) - return aHeapsPerIndex[nNr]; - return 0; -} - void Index::GatherData( const List<Simstr> & i_rInputFileList ) { @@ -192,17 +136,18 @@ Index::WriteOutput( const char * i_sOuputFile ) WriteTableFromHeap( aOut, aService2Module, C_sService, C_sModule, lt_html ); WriteTableFromHeap( aOut, aModule2Service, C_sModule, C_sService, lt_idl ); - for ( unsigned i = 0; i < aTagIndices.nSize; ++i ) - { - WriteTableFromHeap( aOut, *aTagIndices.aTagHeaps[i], - aTagIndices.aTagNames[i], C_sComponentname, lt_html ); - } - WriteStr( aOut, C_sFileEnd ); aOut.close(); } void +Index::InsertSupportedService( const Simstr & i_sService ) +{ + aService2Module.InsertValue( i_sService, sCurModule ); + aModule2Service.InsertValue( sCurModule, i_sService ); +} + +void Index::ReadFile( const char * i_sFilename ) { static char sOutputHtml[1020]; @@ -210,7 +155,9 @@ Index::ReadFile( const char * i_sFilename ) ModuleDescription aModule; X2CParser aParser(aModule); - if ( ! aParser.Parse(i_sFilename) ) + // Parse + bool bResult = aParser.Parse(i_sFilename); + if (! bResult) { cerr << "Error: File \"" << i_sFilename @@ -225,67 +172,15 @@ Index::ReadFile( const char * i_sFilename ) aHtmlCreator.Run(); // GetResults: - Simstr sModuleName = aModule.Name(); - - // Module Tags - const ModuleDescription::ChildList & - rModuleElements = aModule.Children(); - for ( unsigned mi = 1; mi < rModuleElements.size(); ++mi ) - { - Heap * pHeap = aTagIndices.HeapFor(rModuleElements[mi]->Name()); - if (pHeap != 0) - { - unsigned nDatSize = rModuleElements[mi]->Size(); - for ( unsigned d = 0; d < nDatSize; ++d ) - { - pHeap->InsertValue( rModuleElements[mi]->Data(d), sModuleName.str() ); - } - } - } // end for + sCurModule = aModule.ModuleName(); - // Component Tags - const ModuleDescription::CD_List & - rCDs = aModule.Components(); - static char sCD_inModule[1020]; - strcpy( sCD_inModule, sModuleName.str() ); - strcat( sCD_inModule, "," ); - char * pCut = strchr(sCD_inModule,',') + 1; + List< const MultipleTextElement* > aSupportedServices; + aModule.Get_SupportedServices(aSupportedServices); - for ( unsigned cd = 0; cd < rCDs.size(); ++cd ) + for ( unsigned s = 0; s < aSupportedServices.size(); ++s ) { - const ComponentDescription::ChildList & - rCD_Elements = rCDs[cd]->Children(); - strcpy( pCut, rCDs[cd]->Name() ); - for ( unsigned ci = 1; ci < rCD_Elements.size(); ++ci ) - { - if ( ci == 5 ) - { - TextElement * pElem = rCD_Elements[ci]; - unsigned nDatSize = pElem->Size(); - for ( unsigned d = 0; d < nDatSize; ++d ) - { - aService2Module.InsertValue( - pElem->Data(d), - sModuleName ); - aModule2Service.InsertValue( - sModuleName, - pElem->Data(d) ); - } - } - else - { - Heap * pHeap = aTagIndices.HeapFor(rCD_Elements[ci]->Name()); - if (pHeap != 0) - { - unsigned nDatSize = rCD_Elements[ci]->Size(); - for ( unsigned d = 0; d < nDatSize; ++d ) - { - pHeap->InsertValue( rCD_Elements[ci]->Data(d), sCD_inModule ); - } - } - } // end if (ci == 6) else - } // end for - } // for + aSupportedServices[s]->Insert2Index(*this); + } } void @@ -300,17 +195,17 @@ Index::CreateHtmlFileName( char * o_sOutputHtml, #else #error WNT or UNX have to be defined. #endif - strcat( o_sOutputHtml, i_rModule.Name() ); + strcat( o_sOutputHtml, i_rModule.ModuleName() ); strcat( o_sOutputHtml, ".html" ); } void -WriteTableFromHeap( ofstream & o_rOut, - Heap & i_rHeap, - const char * i_sIndexValue, - const char * i_sIndexReference, - E_LinkType i_eLinkType ) +Index::WriteTableFromHeap( ofstream & o_rOut, + Heap & i_rHeap, + const char * i_sIndexValue, + const char * i_sIndexReference, + E_LinkType i_eLinkType ) { WriteStr(o_rOut, "<H3><BR>"); WriteStr(o_rOut, i_sIndexValue ); @@ -325,9 +220,9 @@ WriteTableFromHeap( ofstream & o_rOut, void -WriteHeap( ofstream & o_rOut, - Heap & i_rHeap, - E_LinkType i_eLinkType ) +Index::WriteHeap( ofstream & o_rOut, + Heap & i_rHeap, + E_LinkType i_eLinkType ) { static Simstr S_sKey; static char C_sSpaceInName[] = " "; @@ -373,58 +268,6 @@ WriteHeap( ofstream & o_rOut, WriteStr( o_rOut, "</TD></TR>\n" ); } -int -NrOfTagName( const char * i_sName ) -{ - static const char * aTagNames[C_nNrOfTagNames] = - { -// "module-name", // 1 - "author", // 1 0 -// "name", // 1 -// "description", // 1 - "loader-name", // 1 1 - "language", // 1 2 -// "status", - "supported-service", // + 3 -// "reference-docu", - "service-dependency", // * 4 - "type", // * 5 - "project-build-dependency", // * 6 - "runtime-module-dependency", // * 7 - }; - if (! i_sName) - return -1; - - switch (*i_sName) - { - case 'a': if ( strcmp( aTagNames[0], i_sName ) == 0 ) - return 0; - break; - case 'l': if ( strcmp( aTagNames[1], i_sName ) == 0 ) - return 1; - else if ( strcmp( aTagNames[2], i_sName ) == 0 ) - return 1; - break; - case 's': if ( strcmp( aTagNames[3], i_sName ) == 0 ) - return 3; - else if ( strcmp( aTagNames[4], i_sName ) == 0 ) - return 4; - break; - case 't': if ( strcmp( aTagNames[5], i_sName ) == 0 ) - return 5; - break; - case 'p': if ( strcmp( aTagNames[6], i_sName ) == 0 ) - return 6; - break; - case 'r': if ( strcmp( aTagNames[7], i_sName ) == 0 ) - return 7; - break; - } - return -1; -} - - - /** Übersicht der Struktur @@ -447,6 +290,9 @@ MODULEDESCRIPTION } ProjectBuildDependency* RuntimeModuleDependency* + ReferenceDocu* + ServiceDependency* + Type* } diff --git a/xml2cmp/source/xcd/cr_index.hxx b/xml2cmp/source/xcd/cr_index.hxx index 00472d70b..854814fc2 100644 --- a/xml2cmp/source/xcd/cr_index.hxx +++ b/xml2cmp/source/xcd/cr_index.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cr_index.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,9 +65,9 @@ #include "../support/sistr.hxx" #include "../support/heap.hxx" #include "../support/list.hxx" +#include "../support/syshelp.hxx" -const unsigned C_nNrOfTagNames = 8; class ModuleDescription; @@ -87,40 +87,35 @@ class Index void WriteOutput( const char * i_sOuputFile ); + void InsertSupportedService( + const Simstr & i_sService ); private: - struct IndexedTags - { - public: - IndexedTags( - const List<Simstr> & - i_rTagList ); - ~IndexedTags(); - - Heap * HeapFor( - const char * i_sTagName ); - - DynamicList< Heap > - aTagHeaps; - List< Simstr > aTagNames; - unsigned nSize; - - private: - Heap * aHeapsPerIndex[C_nNrOfTagNames]; - }; - void ReadFile( const char * i_sFilename ); void CreateHtmlFileName( char * o_sOutputHtml, const ModuleDescription & i_rModule ); - + void WriteTableFromHeap( + std::ofstream & o_rOut, + Heap & i_rHeap, + const char * i_sIndexKey, + const char * i_sIndexReference, + E_LinkType i_eLinkType ); + void WriteHeap( + std::ofstream & o_rOut, + Heap & i_rHeap, + E_LinkType i_eLinkType ); + + // DATA Heap aService2Module; Heap aModule2Service; - IndexedTags aTagIndices; Simstr sOutputDirectory; Simstr sIdlRootPath; + + // Temporary Data + Simstr sCurModule; }; diff --git a/xml2cmp/source/xcd/cr_metho.cxx b/xml2cmp/source/xcd/cr_metho.cxx index 9376bb1c9..e0826ce9e 100644 --- a/xml2cmp/source/xcd/cr_metho.cxx +++ b/xml2cmp/source/xcd/cr_metho.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cr_metho.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -77,7 +77,7 @@ char C_sFileHeader2[] = " */\r\n/* Implementation of component_getDescriptionFun char C_sFuncBegin[] = "#ifdef __cplusplus\r\n" "extern \"C\" {\r\n" "#endif\r\n\r\n" - "const sal_Char * SAL_CALL\ncomponent_getDescriptionFunc()\r\n" + "const sal_Char * SAL_CALL\r\ncomponent_getDescriptionFunc()\r\n" "{\r\n" " return (sal_Char*) \r\n" " \""; diff --git a/xml2cmp/source/xcd/cr_metho.hxx b/xml2cmp/source/xcd/cr_metho.hxx index 2542560c7..b4ea9c936 100644 --- a/xml2cmp/source/xcd/cr_metho.hxx +++ b/xml2cmp/source/xcd/cr_metho.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cr_metho.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/xcd/filebuff.cxx b/xml2cmp/source/xcd/filebuff.cxx index 1fe12af35..4a39bed8f 100644 --- a/xml2cmp/source/xcd/filebuff.cxx +++ b/xml2cmp/source/xcd/filebuff.cxx @@ -2,9 +2,9 @@ * * $RCSfile: filebuff.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/xcd/filebuff.hxx b/xml2cmp/source/xcd/filebuff.hxx index 3f0f0aa81..6128140df 100644 --- a/xml2cmp/source/xcd/filebuff.hxx +++ b/xml2cmp/source/xcd/filebuff.hxx @@ -2,9 +2,9 @@ * * $RCSfile: filebuff.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses diff --git a/xml2cmp/source/xcd/main.cxx b/xml2cmp/source/xcd/main.cxx index 807c6ff03..f18d769e1 100644 --- a/xml2cmp/source/xcd/main.cxx +++ b/xml2cmp/source/xcd/main.cxx @@ -2,9 +2,9 @@ * * $RCSfile: main.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ + * last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,37 +68,22 @@ #include "cr_metho.hxx" #include "cr_html.hxx" #include "cr_index.hxx" +#include "xmlelem.hxx" #include "xmltree.hxx" #include "parse.hxx" #include "../support/syshelp.hxx" #include "../support/heap.hxx" -#ifdef WNT -#include <io.h> -#elif defined(UNX) -#include <sys/types.h> -#include <sys/stat.h> -#include <dirent.h> -#define stricmp strcasecmp -#else -#error Must run under unix or windows, please define UNX or WNT. -#endif -using std::cerr; +using namespace std; int Do_IndexCommandLine( const CommandLine & i_rCommandLine ); int Do_SingleFileCommandLine( const CommandLine & i_rCommandLine ); -void GatherFileNames( - List<Simstr> & o_sFiles, - const char * i_sSrcDirectory ); -void GatherSubDirectories( - List<Simstr> & o_sSubDirectories, - const char * i_sParentdDirectory ); void Create_TypeInfoFile( const char * o_sOutputFile, ModuleDescription & i_rData ); @@ -117,7 +102,7 @@ main( int argc, if (! aCommandLine.IsOk()) { - cerr << aCommandLine.ErrorText() << std::endl; + cerr << aCommandLine.ErrorText() << endl; return 1; } @@ -136,20 +121,30 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine) ModuleDescription aDescr; X2CParser aParser(aDescr); - // Parse - bool bParseResult = aParser.Parse(i_rCommandLine.XmlSrcFile()); - if (! bParseResult) + // Load file and create Function-file + bool bLoadResult = aParser.LoadFile(i_rCommandLine.XmlSrcFile()); + if (! bLoadResult) { - cerr << "Error: File %s could not be parsed." << i_rCommandLine.XmlSrcFile() << std::endl; + cerr << "Error: File %s could not be loaded." << i_rCommandLine.XmlSrcFile() << endl; return 1; } - // Produce output if ( strlen(i_rCommandLine.FuncFile()) > 0 ) { Create_AccessMethod( i_rCommandLine.FuncFile(), aParser.PureText() ); } + + cout << "File " + << i_rCommandLine.FuncFile() + << " with component_getDescriptionFunc() is created now." + << endl; + + + // Parse + aParser.Parse(); + + // Produce output if ( strlen(i_rCommandLine.HtmlFile()) > 0 ) { HtmlCreator aHtmlCreator( i_rCommandLine.HtmlFile(), @@ -176,162 +171,19 @@ Do_IndexCommandLine(const CommandLine & i_rCommandLine) i_rCommandLine.IdlRootPath(), i_rCommandLine.IndexedTags() ); - std::cout << "Gather xml-files ..." << std::endl; + std::cout << "Gather xml-files ..." << endl; GatherFileNames( aFiles, i_rCommandLine.XmlSrcDirectory() ); - std::cout << "Create output ..." << std::endl; + std::cout << "Create output ..." << endl; aIndex.GatherData(aFiles); aIndex.WriteOutput( i_rCommandLine.IndexOutputFile() ); - std::cout << "... done." << std::endl; + std::cout << "... done." << endl; return 0; }; -const char C_sXML_END[] = "\\*.xml"; - -void -GatherFileNames( List<Simstr> & o_sFiles, - const char * i_sSrcDirectory ) -{ - static int nAliveCounter = 0; - - char * sNextDir = 0; - Simstr sNew = 0; - -#ifdef WNT - struct _finddata_t aEntry; - long hFile = 0; - int bFindMore = 0; - char * sFilter = new char[ strlen(i_sSrcDirectory) + sizeof C_sXML_END ]; - - // Stayingalive sign - if (++nAliveCounter % 100 == 1) - fprintf(stdout,"."); - - strcpy(sFilter, i_sSrcDirectory); - strcat(sFilter,C_sXML_END); - - hFile = _findfirst( sFilter, &aEntry ); - for ( bFindMore = hFile == -1; - bFindMore == 0; - bFindMore = _findnext( hFile, &aEntry ) ) - { - sNew = i_sSrcDirectory; - sNew += "\\"; - sNew += aEntry.name; - o_sFiles.push_back(sNew); - } // end for - - _findclose(hFile); - delete [] sFilter; -#elif defined(UNX) - DIR * pDir = opendir( i_sSrcDirectory ); - dirent * pEntry = 0; - char * sEnding; - - while ( (pEntry = readdir(pDir)) != 0 ) - { - sEnding = strrchr(pEntry->d_name,'.'); - if (sEnding != 0 ? stricmp(sEnding,".xml") == 0 : 0 ) - { - sNew = i_sSrcDirectory; - sNew += "/"; - sNew += pEntry->d_name; - o_sFiles.push_back(sNew); - } - } // end while - - closedir( pDir ); -#else -#error Must run on unix or windows, please define UNX or WNT. -#endif - - // gathering from subdirectories: - List<Simstr> aSubDirectories; - GatherSubDirectories( aSubDirectories, i_sSrcDirectory ); - - unsigned d_max = aSubDirectories.size(); - for ( unsigned d = 0; d < d_max; ++d ) - { - sNextDir = new char[ strlen(i_sSrcDirectory) + 2 + aSubDirectories[d].l() ]; - - strcpy(sNextDir, i_sSrcDirectory); - strcat(sNextDir, C_sSLASH); - strcat(sNextDir, aSubDirectories[d].str()); - GatherFileNames(o_sFiles, sNextDir); - - delete [] sNextDir; - } -} - - -const char * C_sANYDIR = "\\*.*"; - -void -GatherSubDirectories( List<Simstr> & o_sSubDirectories, - const char * i_sParentdDirectory ) -{ - Simstr sNew; - -#ifdef WNT - struct _finddata_t aEntry; - long hFile = 0; - int bFindMore = 0; - char * sFilter = new char[strlen(i_sParentdDirectory) + sizeof C_sANYDIR]; - - strcpy(sFilter, i_sParentdDirectory); - strcat(sFilter,C_sANYDIR); - - hFile = _findfirst( sFilter, &aEntry ); - for ( bFindMore = hFile == -1; - bFindMore == 0; - bFindMore = _findnext( hFile, &aEntry ) ) - { - if (aEntry.attrib == _A_SUBDIR) - { - // Do not gather . .. and outputtree directories - if ( strchr(aEntry.name,'.') == 0 - && strncmp(aEntry.name, "wnt", 3) != 0 - && strncmp(aEntry.name, "unx", 3) != 0 ) - { - sNew = aEntry.name; - o_sSubDirectories.push_back(sNew); - } - } // endif (aEntry.attrib == _A_SUBDIR) - } // end for - _findclose(hFile); - delete [] sFilter; - -#elif defined(UNX) - DIR * pDir = opendir( i_sParentdDirectory ); - dirent * pEntry = 0; - struct stat aEntryStatus; - char * sEnding; - - while ( ( pEntry = readdir(pDir) ) != 0 ) - { - stat(pEntry->d_name, &aEntryStatus); - if ( ( aEntryStatus.st_mode & S_IFDIR ) == S_IFDIR ) - { - // Do not gather . .. and outputtree directories - if ( strchr(pEntry->d_name,'.') == 0 - && strncmp(pEntry->d_name, "wnt", 3) != 0 - && strncmp(pEntry->d_name, "unx", 3) != 0 ) - { - sNew = pEntry->d_name; - o_sSubDirectories.push_back(sNew); - } - } // endif (aEntry.attrib == _A_SUBDIR) - } // end while - closedir( pDir ); -#else -#error Must run on unix or windows, please define UNX or WNT. -#endif -} - - void Create_TypeInfoFile( const char * o_sOutputFile, @@ -344,41 +196,27 @@ Create_TypeInfoFile( const char * o_sOutputFile, ); if ( !aOut ) { - cerr << "Error: " << o_sOutputFile << " could not be created." << std::endl; + cerr << "Error: " << o_sOutputFile << " could not be created." << endl; return; } Heap aTypesHeap(12); - Simstr sLibPrefix = i_rData.Children()[0]->Data(); + Simstr sLibPrefix = i_rData.ModuleName(); // Gather types: - const ModuleDescription::CD_List & rListDescriptions = i_rData.Components(); + List< const MultipleTextElement * > aTypes; + i_rData.Get_Types(aTypes); - // Descriptions: - for ( unsigned nDescrIter = 0; nDescrIter < rListDescriptions.size(); ++nDescrIter ) + for ( unsigned t = 0; t < aTypes.size(); ++t ) { - // Find Type-Tag: - TextElement * pTypes = 0; - ComponentDescription::ChildList & rTags = rListDescriptions[nDescrIter]->Children(); - for ( unsigned nTagIter = 0; nTagIter < rTags.size(); ++nTagIter ) + unsigned i_max = aTypes[t]->Size(); + for ( unsigned i = 0; i < i_max; ++i ) { - if ( strcmp( rTags[nTagIter]->Name(),"type") == 0 ) - { - pTypes = rTags[nTagIter]; - break; - } - } // end for (aTagIter) - - if ( pTypes != 0) - { - for ( unsigned nTypeIter = 0; nTypeIter < pTypes->Size(); ++nTypeIter ) - { // Loop Services - aTypesHeap.InsertValue( pTypes->Data(nTypeIter), "" ); - } // end for aDataIter - } - } // end for (aDescrIter) + aTypesHeap.InsertValue( aTypes[t]->Data(i), "" ); + } // end for + } - // Write types: + // Write types: WriteStr( aOut, sLibPrefix ); WriteStr( aOut, "_XML2CMPTYPES= "); diff --git a/xml2cmp/source/xcd/makefile.mk b/xml2cmp/source/xcd/makefile.mk index a97edf0a9..29901c6ff 100644 --- a/xml2cmp/source/xcd/makefile.mk +++ b/xml2cmp/source/xcd/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: np $ $Date: 2001-03-12 19:24:52 $ +# last change: $Author: np $ $Date: 2001-03-23 13:24:04 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -76,13 +76,26 @@ TARGETTYPE=CUI # --- Files -------------------------------------------------------- -OBJFILES= \ +LIB1TARGET=$(LB)$/$(TARGET).lib +LIB1OBJFILES=\ $(OBJ)$/main.obj \ $(OBJ)$/cr_html.obj \ $(OBJ)$/cr_index.obj \ $(OBJ)$/cr_metho.obj \ $(OBJ)$/filebuff.obj \ $(OBJ)$/parse.obj \ + $(OBJ)$/xmlelem.obj \ + $(OBJ)$/xmltree.obj + + +LIB2TARGET=$(LB)$/$(TARGET)l.lib +LIB2OBJFILES=\ + $(OBJ)$/cr_html.obj \ + $(OBJ)$/cr_index.obj \ + $(OBJ)$/cr_metho.obj \ + $(OBJ)$/filebuff.obj \ + $(OBJ)$/parse.obj \ + $(OBJ)$/xmlelem.obj \ $(OBJ)$/xmltree.obj @@ -90,6 +103,7 @@ OBJFILES= \ # --- Targets ------------------------------------------------------ + .INCLUDE : target.mk diff --git a/xml2cmp/source/xcd/parse.cxx b/xml2cmp/source/xcd/parse.cxx index 3c715b0da..5f63df60b 100644 --- a/xml2cmp/source/xcd/parse.cxx +++ b/xml2cmp/source/xcd/parse.cxx @@ -2,7 +2,7 @@ * * $RCSfile: parse.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * * last change: $Author: np $Date: $ * @@ -64,45 +64,31 @@ #include <string.h> #include <iostream> -#include <xmltree.hxx> +#include <xmlelem.hxx> #ifdef UNX #define strnicmp strncasecmp #endif -using std::cerr; +using namespace std; // NOT FULLY DEFINED SERVICES -char C_sMODULEDESCRIPTION[] = "module-description"; -char C_sCOMPONENTDESCRIPTION[] = "component-description"; -char C_sAuthor[] = "author"; -char C_sName[] = "name"; -char C_sDescription[] = "description"; -char C_sReferenceDocu[] = "reference-docu"; -char C_sModuleName[] = "module-name"; -char C_sLoaderName[] = "loader-name"; -char C_sSupportedService[] = "supported-service"; -char C_sServiceDependency[] = "service-dependency"; -char C_sProjectBuildDependency[] = "project-build-dependency"; -char C_sRuntimeModuleDependency[] = "runtime-module-dependency"; -char C_sLanguage[] = "language"; -char C_sStatus[] = "status"; -char C_sType[] = "type"; - #define AssertionOf(x) \ {if (!(x)) {cerr << "Assertion failed: " << #x << __FILE__ << __LINE__ << std::endl; exit(3); }} -#define SyntaxAssertion(x,file) \ - {if (!(x)) {cerr << "Syntax error in file: " << #file << std::endl; exit(3); }} -X2CParser::X2CParser( ModuleDescription & o_rData ) - : pData(&o_rData) +X2CParser::X2CParser( XmlElement & o_rDocumentData ) + : // sFileName, + nFileLine(0), + pDocumentData(&o_rDocumentData), + // sWord, + text(0) { } @@ -110,9 +96,13 @@ X2CParser::~X2CParser() { } + bool -X2CParser::Parse( const char * i_sFilename ) +X2CParser::LoadFile( const char * i_sFilename ) { + sFileName = i_sFilename; + nFileLine = 1; + // Load file: if ( ! LoadXmlFile( aFile, i_sFilename ) ) return false; @@ -121,20 +111,33 @@ X2CParser::Parse( const char * i_sFilename ) const char * pLastTag = strrchr(aFile.operator const char *(),'<'); if (pLastTag == 0) return false; - if ( strnicmp(pLastTag+2, C_sMODULEDESCRIPTION, strlen(C_sMODULEDESCRIPTION)) != 0 + if ( strnicmp(pLastTag+2, pDocumentData->Name().str(), pDocumentData->Name().l()) != 0 || strnicmp(pLastTag, "</", 2) != 0 ) return false; if (strchr(pLastTag,'>') == 0) return false; + return true; +} +void +X2CParser::Parse() +{ // Parse: text = aFile.operator const char *(); Parse_XmlDeclaration(); Parse_Doctype(); - Parse_ModuleDescription(); - return true; + pDocumentData->Parse(*this); +} + +bool +X2CParser::Parse( const char * i_sFilename ) +{ + bool ret = LoadFile(i_sFilename); + if (ret) + Parse(); + return ret; } void @@ -156,176 +159,149 @@ X2CParser::Parse_Doctype() } void -X2CParser::Parse_ModuleDescription() +X2CParser::Parse_Sequence( DynamicList<XmlElement> & o_rElements, + const Simstr & i_sElementName ) { - Goto('<'); - AssertionOf( IsBeginTag(C_sMODULEDESCRIPTION) ); - Goto_And_Pass('>'); + CheckAndPassBeginTag(i_sElementName.str()); - Parse_TextElement(C_sModuleName,*pData, true, false); - - for ( Goto('<'); - IsBeginTag(C_sCOMPONENTDESCRIPTION); - Goto('<') ) + unsigned int i_max = o_rElements.size(); + for (unsigned i = 0; i < i_max; ++i) { - Parse_ComponentDescription(*pData); - } + o_rElements[i]->Parse(*this); + } // end for - for ( ; ! IsEndTag(C_sMODULEDESCRIPTION); Goto('<') ) - { - if ( IsBeginTag(C_sProjectBuildDependency) ) - Parse_TextElement(C_sProjectBuildDependency,*pData,false,false); - else if ( IsBeginTag(C_sRuntimeModuleDependency) ) - Parse_TextElement(C_sRuntimeModuleDependency,*pData,false,false); - } - Goto_And_Pass('>'); + CheckAndPassEndTag(i_sElementName.str()); } void -X2CParser::Parse_ComponentDescription(ModuleDescription & o_rParent) +X2CParser::Parse_FreeChoice( DynamicList<XmlElement> & o_rElements ) { - Goto('<'); - AssertionOf( IsBeginTag(C_sCOMPONENTDESCRIPTION) ); - Goto_And_Pass('>'); - - ComponentDescription * dpCD = new ComponentDescription; - o_rParent.AddComponentDescription(*dpCD); - - Parse_TextElement(C_sAuthor,*dpCD,true,false); - Parse_TextElement(C_sName,*dpCD,true,true); - Parse_TextElement(C_sDescription,*dpCD,true,false); - Parse_TextElement(C_sLoaderName,*dpCD,true,true); - Parse_TextElement(C_sLanguage,*dpCD,true,false); - Parse_Status(*dpCD); - for ( Goto('<'); - IsBeginTag(C_sSupportedService); - Goto('<') ) - { - Parse_TextElement(C_sSupportedService,*dpCD,false,true); - } + unsigned nSize = o_rElements.size(); - for ( Goto('<'); - ! IsEndTag(C_sCOMPONENTDESCRIPTION); - Goto('<') ) + for ( bool bBreak = false; !bBreak; ) { - if ( IsBeginTag(C_sReferenceDocu) ) + bBreak = true; + for ( unsigned i = 0; i < nSize; ++i ) { - ReferenceDocuElement * pNewElem = new ReferenceDocuElement; - Parse_ReferenceDocu(*pNewElem); - dpCD->DocuRefs().push_back(pNewElem); - } - else if ( IsBeginTag(C_sServiceDependency) ) - Parse_TextElement(C_sServiceDependency,*dpCD,false,true); - else if ( IsBeginTag(C_sType) ) - Parse_TextElement(C_sType,*dpCD,false,true); - } - Goto_And_Pass('>'); - - // Take Name to front: - ParentElement::ChildList & rDescrElements = dpCD->Children(); - TextElement * pTE = rDescrElements[0]; - rDescrElements[0] = rDescrElements[1]; - rDescrElements[1] = pTE; + Goto('<'); + if ( IsBeginTag(o_rElements[i]->Name().str()) ) + { + o_rElements[i]->Parse(*this); + bBreak = false; + break; + } + } // end for i + } // end for !bBreak } void -X2CParser::Parse_ReferenceDocu(ReferenceDocuElement & o_rElement) +X2CParser::Parse_List( ListElement & o_rListElem ) { - Move( strlen(C_sReferenceDocu) + 1 ); - for ( Pass_White(); *text != '/'; Pass_White() ) + for ( Goto('<'); IsBeginTag(o_rListElem.Name().str()); Goto('<') ) { - Get_ReferenceDocuAttribute(o_rElement); + XmlElement * pNew = o_rListElem.Create_and_Add_NewElement(); + pNew->Parse(*this); } - Move(1); } void -X2CParser::Parse_TextElement( const char * i_sElementName, - ParentElement & o_rParent, - bool i_bSingle, - bool i_bReverseName ) +X2CParser::Parse_Text( Simstr & o_sText, + const Simstr & i_sElementName, + bool i_bReverseName ) { - Goto('<'); - text++; - AssertionOf( IsText(i_sElementName) ); - Goto_And_Pass('>'); - Pass_White(); + CheckAndPassBeginTag(i_sElementName.str()); - TextElement * pNew = 0; + // Add new Element + GetTextTill( o_sText, '<', i_bReverseName ); + o_sText.remove_trailing_blanks(); - if ( !i_bSingle && o_rParent.Children().size() > 0 ) - { - if ( strcmp( o_rParent.Children().back()->Name(), - i_sElementName ) == 0 ) - { - pNew = o_rParent.Children().back(); - } - } - if (pNew == 0) + CheckAndPassEndTag(i_sElementName.str()); +} + +void +X2CParser::Parse_MultipleText( List<Simstr> & o_rTexts, + const Simstr & i_sElementName, + bool i_bReverseName ) +{ + for ( Goto('<'); IsBeginTag(i_sElementName.str()); Goto('<') ) { - pNew = i_bSingle - ? (TextElement*) new SglTextElement(i_sElementName) - : (TextElement*) new MultipleTextElement(i_sElementName); - o_rParent.AddChild(*pNew); + o_rTexts.push_back(Simstr()); + Parse_Text(o_rTexts.back(), i_sElementName, i_bReverseName); } - - // Add new Element - Simstr sText; - GetTextTill( sText, '<', i_bReverseName ); - sText.remove_trailing_blanks(); - pNew->SetText(sText); - - AssertionOf( IsText("</") ); - Move(2); - AssertionOf( IsText(i_sElementName) ); - Goto_And_Pass('>'); } void -X2CParser::Parse_Status( ComponentDescription & o_rParent ) +X2CParser::Parse_SglAttr( Simstr & o_sAttrValue, + const Simstr & i_sElementName, + const Simstr & i_sAttrName ) { Goto('<'); - AssertionOf( IsBeginTag(C_sStatus) ); - Move( strlen(C_sStatus) + 1 ); + if ( !IsBeginTag(i_sElementName.str()) ) + SyntaxError("unexpected element"); + Move( i_sElementName.l() + 1 ); Pass_White(); - AssertionOf(*text != '>'); + if (*text == '>') + SyntaxError("no attribute found, where one was expected"); Simstr sAttrName; - Simstr sAttrValue = Get_Attribute(sAttrName); - o_rParent.SetStatus(sAttrValue); - + Get_Attribute(o_sAttrValue, sAttrName); + if (sAttrName != i_sAttrName) + SyntaxError("unknown attribute found"); + Pass_White(); + if (strncmp(text,"/>",2) != 0) + SyntaxError("missing \"/>\" at end of empty element"); Move(2); } void -X2CParser::Get_ReferenceDocuAttribute( ReferenceDocuElement & o_rElement ) +X2CParser::Parse_MultipleAttr( List<Simstr> & o_rAttrValues, + const Simstr & i_sElementName, + const List<Simstr> & i_rAttrNames ) { + Goto('<'); + if ( !IsBeginTag(i_sElementName.str()) ) + SyntaxError("unexpected element"); + Move( i_sElementName.l() + 1 ); Simstr sAttrName; - Simstr sAttrValue = Get_Attribute(sAttrName); - if ( strcmp( sAttrName.str(), "xlink:href") == 0 ) - o_rElement.sAttr_href = sAttrValue; - else if ( strcmp( sAttrName.str(), "xlink:role") == 0 ) - o_rElement.sAttr_role = sAttrValue; - else if ( strcmp( sAttrName.str(), "xlink:title") == 0 ) - o_rElement.sAttr_title = sAttrValue; + Simstr sAttrValue; + unsigned nSize = i_rAttrNames.size(); + + for ( Pass_White(); *text != '/'; Pass_White() ) + { + + Get_Attribute(sAttrValue, sAttrName); + + for ( unsigned i = 0; i < nSize; ++i ) + { + if ( i_rAttrNames[i] == sAttrName ) + { + o_rAttrValues[i] = sAttrValue; + break; + } + } + if (i == nSize) + SyntaxError("unknown attribute found"); + } + Move(2); } -Simstr -X2CParser::Get_Attribute( Simstr & o_rAttrName ) + +void +X2CParser::Get_Attribute( Simstr & o_rAttrValue, + Simstr & o_rAttrName ) { GetTextTill( o_rAttrName, '='); while (*(++text) != '"') { - AssertionOf(*text != '\0'); + if (*text == '\0') + SyntaxError("unexpected end of file"); } ++text; - Simstr ret; - GetTextTill( ret, '"'); + GetTextTill( o_rAttrValue, '"'); ++text; - return ret; } bool @@ -353,8 +329,8 @@ X2CParser::Goto( char i_cNext ) { while (*text != i_cNext) { + TestCurChar(); ++text; - AssertionOf(*text != '\0'); } } @@ -376,8 +352,8 @@ X2CParser::Pass_White() { while (*text <= 32) { + TestCurChar(); ++text; - AssertionOf(*text != '\0'); } } @@ -392,7 +368,7 @@ X2CParser::GetTextTill( Simstr & o_rText, *text != i_cEnd; ++text ) { - AssertionOf(*text !='\0'); + TestCurChar(); *pSet++ = *text; } @@ -426,4 +402,50 @@ X2CParser::GetTextTill( Simstr & o_rText, o_rText = &sWord[0]; } +void +X2CParser::CheckAndPassBeginTag( const char * i_sElementName ) +{ + Goto('<'); + if ( ! IsBeginTag(i_sElementName) ) + SyntaxError( "unexpected element"); + Goto_And_Pass('>'); + Pass_White(); + +} + +void +X2CParser::CheckAndPassEndTag( const char * i_sElementName ) +{ + Pass_White(); + if ( !IsEndTag(i_sElementName) ) + SyntaxError("missing or not matching end tag"); + Goto_And_Pass('>'); +} + +void +X2CParser::SyntaxError( const char * i_sText ) +{ + cerr << "Syntax error " + << i_sText + << " in file: " + << sFileName.str() + << " in line " + << nFileLine + << "." + << endl; + + exit(3); +} + +void +X2CParser::TestCurChar() +{ +// if (*text == '\0') +// SyntaxError("unexpected end of file"); +// else + + if (*text == '\n') + nFileLine++; +} + diff --git a/xml2cmp/source/xcd/parse.hxx b/xml2cmp/source/xcd/parse.hxx index 0cfe64bd7..cf547269f 100644 --- a/xml2cmp/source/xcd/parse.hxx +++ b/xml2cmp/source/xcd/parse.hxx @@ -2,7 +2,7 @@ * * $RCSfile: parse.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * * last change: $Author: np $Date: $ * @@ -69,47 +69,65 @@ // COMPONENTS #include "filebuff.hxx" #include "../support/sistr.hxx" +#include "../support/list.hxx" // PARAMETERS -class ModuleDescription; -class ParentElement; -class ComponentDescription; -class ReferenceDocuElement; +class XmlElement; +class ListElement; class X2CParser { public: + typedef XmlElement * (*F_CREATE)(const Simstr &); + X2CParser( - ModuleDescription & o_rData ); + XmlElement & o_rDocumentData ); ~X2CParser(); - bool Parse( + bool LoadFile( + const char * i_sFilename ); + void Parse(); + bool Parse( const char * i_sFilename ); + + const char * PureText() const { return aFile.operator const char*(); } + void Parse_Sequence( + DynamicList<XmlElement> & + o_rElements, + const Simstr & i_sElementName ); + void Parse_FreeChoice( + DynamicList<XmlElement> & + o_rElements ); + void Parse_List( + ListElement & o_rListElem ); + void Parse_Text( + Simstr & o_sText, + const Simstr & i_sElementName, + bool i_bReverseName ); + void Parse_MultipleText( + List<Simstr> & o_rTexts, + const Simstr & i_sElementName, + bool i_bReverseName ); + void Parse_SglAttr( + Simstr & o_sAttrValue, + const Simstr & i_sElementName, + const Simstr & i_sAttrName ); + void Parse_MultipleAttr( + List<Simstr> & o_rAttrValues, + const Simstr & i_sElementName, + const List<Simstr> & + i_rAttrNames ); + private: void Parse_XmlDeclaration(); void Parse_Doctype(); - void Parse_ModuleDescription(); - void Parse_ComponentDescription( - ModuleDescription & o_rParent ); - void Parse_ReferenceDocu( - ReferenceDocuElement & - o_rElement ); - void Parse_TextElement( - const char * i_sElementName, - ParentElement & o_rParent, - bool i_bSingle, - bool i_bReverseName ); - void Parse_Status( - ComponentDescription & - o_rParent ); - void Get_ReferenceDocuAttribute( - ReferenceDocuElement & - o_rElement ); - Simstr Get_Attribute( - Simstr & o_rAttrName ); + + void Get_Attribute( + Simstr & o_rAttrValue, + Simstr & o_rAttrName ); bool IsText( const char * i_sComparedText ); bool IsBeginTag( @@ -127,10 +145,22 @@ class X2CParser Simstr & o_rText, char i_cEnd, bool i_bReverseName = false ); + void CheckAndPassBeginTag( + const char * i_sElementName ); + void CheckAndPassEndTag( + const char * i_sElementName ); + + + void SyntaxError( + const char * i_sText ); + void TestCurChar(); // DATA + Simstr sFileName; + unsigned nFileLine; + Buffer aFile; - ModuleDescription * pData; + XmlElement * pDocumentData; char sWord[8192]; const char * text; diff --git a/xml2cmp/source/xcd/xmltree.cxx b/xml2cmp/source/xcd/xmltree.cxx index f3feb47dc..6a059324f 100644 --- a/xml2cmp/source/xcd/xmltree.cxx +++ b/xml2cmp/source/xcd/xmltree.cxx @@ -2,7 +2,7 @@ * * $RCSfile: xmltree.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * * last change: $Author: np $Date: $ * @@ -64,86 +64,257 @@ // NOT FULLY DEFINED SERVICES +#include <cr_html.hxx> +#include <cr_index.hxx> +char C_sMODULEDESCRIPTION[] = "module-description"; +char C_sCOMPONENTDESCRIPTION[] = "component-description"; +char C_sAuthor[] = "author"; +char C_sName[] = "name"; +char C_sDescription[] = "description"; +char C_sReferenceDocu[] = "reference-docu"; +char C_sModuleName[] = "module-name"; +char C_sLoaderName[] = "loader-name"; +char C_sSupportedService[] = "supported-service"; +char C_sServiceDependency[] = "service-dependency"; +char C_sProjectBuildDependency[] = "project-build-dependency"; +char C_sRuntimeModuleDependency[] = "runtime-module-dependency"; +char C_sLanguage[] = "language"; +char C_sStatus[] = "status"; +char C_sType[] = "type"; +char C_sAttr_value[] = "value"; +char C_sAttr_xl_href[] = "xlink:href"; +char C_sAttr_xl_role[] = "xlink:role"; +char C_sAttr_xl_title[] = "xlink:title"; +char C_sAttr_xmlns[] = "xmlns:xlink"; +char C_sAttr_xl_type[] = "xlink:type"; +char C_sCompDescrListTitle[] = "Component Descriptions"; + + +FreeChoiceElement * Create_ModuleDescrOptional_Element( + MultipleTextElement * & + o_rTypes, + MultipleTextElement * & + o_rServiceDependencies ); +FreeChoiceElement * Create_CompDescrOptional_Element( + MultipleTextElement * & + o_rTypes, + MultipleTextElement * & + o_rServiceDependencies ); + + + +ModuleDescription::ModuleDescription() + : SequenceElement(C_sMODULEDESCRIPTION), + pModuleName(0), + pCdList(0), + pTypes(0), + pServiceDependencies(0) +{ + pModuleName = new MdName; + AddChild( *pModuleName ); + pCdList = new CompDescrList; + AddChild( *pCdList ); + AddChild( *Create_ModuleDescrOptional_Element( pTypes, pServiceDependencies ) ); +} + +const Simstr & +ModuleDescription::ModuleName() const +{ + return pModuleName->Data(); +} + void -ParentElement::AddChild( TextElement & let_drElement ) +ModuleDescription::Get_SupportedServices( List< const MultipleTextElement * > & o_rServices ) const { - aChildren.push_back(&let_drElement); + o_rServices.push_back(pServiceDependencies); + pCdList->Get_SupportedServices( o_rServices ); } +void +ModuleDescription::Get_Types( List< const MultipleTextElement * > & o_rTypes ) const +{ + o_rTypes.push_back(pTypes); + pCdList->Get_Types( o_rTypes ); +} + +void +ModuleDescription::Get_ServiceDependencies( List< const MultipleTextElement * > & o_rServices ) const +{ + pCdList->Get_ServiceDependencies( o_rServices ); +} + +ComponentDescription::ComponentDescription() + : SequenceElement(C_sCOMPONENTDESCRIPTION,1), + pComponentName(0), + pSupportedServices(0), + pTypes(0), + pServiceDependencies(0) +{ + AddChild( *new SglTextElement(C_sAuthor, lt_nolink, false) ); + pComponentName = new CdName; + AddChild( *pComponentName ); + AddChild( *new SglTextElement(C_sDescription, lt_nolink, false) ); + AddChild( *new SglTextElement(C_sLoaderName, lt_idl, true) ); + AddChild( *new SglTextElement(C_sLanguage, lt_nolink, false) ); + AddChild( *new SglAttrElement(C_sStatus, C_sAttr_value) ); + pSupportedServices = new SupportedService; + AddChild( *pSupportedServices ); + AddChild( *Create_CompDescrOptional_Element( pTypes, pServiceDependencies ) ); +} + +CompDescrList::CompDescrList() + : ListElement(C_sCOMPONENTDESCRIPTION, 0) +{ +} void -ModuleDescription::AddComponentDescription( ComponentDescription & let_drCD ) +CompDescrList::Write2Html( HtmlCreator & io_rHC ) const +{ + io_rHC.StartBigCell(C_sCompDescrListTitle); + ListElement::Write2Html(io_rHC); + io_rHC.FinishBigCell(); +} + +XmlElement * +CompDescrList::Create_and_Add_NewElement() { - aCDs.push_back(&let_drCD); -} + ComponentDescription * pCD = new ComponentDescription; + Children().push_back(pCD); + aCDs.push_back(pCD); + return pCD; +} void -ComponentDescription::SetStatus( const char * i_sText ) +CompDescrList::Get_SupportedServices( List< const MultipleTextElement * > & o_rResult ) const { - sStatus = i_sText; + unsigned i_max = aCDs.size();; + for (unsigned i = 0; i < i_max; ++i) + { + o_rResult.push_back(& aCDs[i]->SupportedServices()); + } // end for } -SglTextElement::SglTextElement( const char * i_sName ) - : sName(i_sName) +void +CompDescrList::Get_Types( List< const MultipleTextElement * > & o_rResult ) const { + unsigned i_max = aCDs.size();; + for (unsigned i = 0; i < i_max; ++i) + { + o_rResult.push_back(& aCDs[i]->Types()); + } // end for } void -SglTextElement::SetText( const char * i_sText ) +CompDescrList::Get_ServiceDependencies( List< const MultipleTextElement * > & o_rResult ) const { - sContent = i_sText; + unsigned i_max = aCDs.size();; + for (unsigned i = 0; i < i_max; ++i) + { + o_rResult.push_back(& aCDs[i]->ServiceDependencies()); + } // end for } -const char * -SglTextElement::Name() const +MdName::MdName() + : SglTextElement(C_sModuleName, lt_html, false) { - return sName; } -const char * -SglTextElement::Data( unsigned i_nNr ) const +void +MdName::Write2Html( HtmlCreator & io_rHC ) const { - return sContent.str(); + io_rHC.Write_SglTextElement( *this, true ); } -unsigned -SglTextElement::Size() const +CdName::CdName() + : SglTextElement(C_sName, lt_html, true) { - return 1; } +void +CdName::Write2Html( HtmlCreator & io_rHC ) const +{ + io_rHC.Write_SglTextElement( *this, true ); +} -MultipleTextElement::MultipleTextElement( const char * i_sName ) - : sName(i_sName) +SupportedService::SupportedService() + : MultipleTextElement(C_sSupportedService, lt_idl, true) { } void -MultipleTextElement::SetText( const char * i_sText ) +SupportedService::Insert2Index( Index & o_rIndex ) const { - aContent.push_back(i_sText); + for ( unsigned i = 0; i < Size(); ++i ) + { + o_rIndex.InsertSupportedService( Data(i) ); + } } -const char * -MultipleTextElement::Name() const +FreeChoiceElement * +Create_ModuleDescrOptional_Element( MultipleTextElement * & o_rTypes, + MultipleTextElement * & o_rServiceDependencies ) { - return sName; + FreeChoiceElement * ret = Create_CompDescrOptional_Element( o_rTypes, o_rServiceDependencies ); + + ret->AddChild( *new MultipleTextElement(C_sProjectBuildDependency, lt_nolink, false) ); + ret->AddChild( *new MultipleTextElement(C_sRuntimeModuleDependency, lt_nolink, false) ); + return ret; } -const char * -MultipleTextElement::Data( unsigned i_nNr ) const +FreeChoiceElement * +Create_CompDescrOptional_Element( MultipleTextElement * & o_rTypes, + MultipleTextElement * & o_rServiceDependencies ) { - if (i_nNr < aContent.size()) - return aContent[i_nNr].str(); - else - return ""; + FreeChoiceElement * ret = new FreeChoiceElement; + const unsigned C_sRefDocuAttrNumber = 5; + static const char * C_sRefDocuAttrNames[C_sRefDocuAttrNumber] + = { C_sAttr_xl_href, C_sAttr_xl_role, C_sAttr_xl_title, C_sAttr_xmlns, C_sAttr_xl_type }; + + ret->AddChild( *new MultipleAttrElement(C_sReferenceDocu, C_sRefDocuAttrNames, C_sRefDocuAttrNumber) ); + o_rServiceDependencies = new MultipleTextElement(C_sServiceDependency, lt_idl, true); + ret->AddChild( *o_rServiceDependencies ); + o_rTypes = new MultipleTextElement(C_sType, lt_idl, true); + ret->AddChild( *o_rTypes ); + return ret; } -unsigned -MultipleTextElement::Size() const + +#if 0 + +const TextElement * +ModuleDescription::ServiceDependencies() const +{ + const unsigned nEarliestPossibleServiceDependenciesIndexInModules = 1; + + for ( unsigned i = nEarliestPossibleServiceDependenciesIndexInModules; + i < Children().size(); + ++i ) + { + if ( strcmp(Children()[i]->Name(), C_sServiceDependency) == 0 ) + return Children()[i]; + } + return 0; +} + +const TextElement & +ComponentDescription::SupportedServices() const { - return aContent.size(); + return *Children()[C_nSupportedServicesIndex]; } +const TextElement * +ComponentDescription::ServiceDependencies() const +{ + for ( unsigned i = C_nEarliestPossibleServiceDependenciesIndex; i < Children().size(); ++i ) + { + if ( strcmp(Children()[i]->Name(),C_sServiceDependency) == 0) + return Children()[i]; + } + return 0; +} + +#endif + + diff --git a/xml2cmp/source/xcd/xmltree.hxx b/xml2cmp/source/xcd/xmltree.hxx index 6f08b2807..500a1f61c 100644 --- a/xml2cmp/source/xcd/xmltree.hxx +++ b/xml2cmp/source/xcd/xmltree.hxx @@ -2,7 +2,7 @@ * * $RCSfile: xmltree.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * * last change: $Author: np $Date: $ * @@ -66,131 +66,113 @@ // USED SERVICES // BASE CLASSES +#include "xmlelem.hxx" // COMPONENTS #include "../support/sistr.hxx" #include "../support/list.hxx" // PARAMETERS -class ComponentDescription; -class ReferenceDocuElement; +class CompDescrList; -class TextElement +class ModuleDescription : public SequenceElement { public: - virtual void SetText( - const char * i_sText ) = 0; - virtual const char * - Name() const = 0; - virtual const char * - Data( - unsigned i_nNr = 0 ) const = 0; - virtual unsigned Size() const = 0; -}; - -class ParentElement -{ - public: - typedef DynamicList<TextElement> ChildList; - void AddChild( - TextElement & let_drElement ); - - const ChildList & Children() const { return aChildren; } - ChildList & Children() { return aChildren; } - + ModuleDescription(); + + const Simstr & ModuleName() const; + void Get_SupportedServices( /// @return also the children of component-description. + List< const MultipleTextElement * > & + o_rServices ) const; + void Get_Types( + List< const MultipleTextElement * > & + o_rTypes ) const; + void Get_ServiceDependencies( + List< const MultipleTextElement * > & + o_rServices ) const; private: - ChildList aChildren; + SglTextElement * pModuleName; + CompDescrList * pCdList; + MultipleTextElement * + pTypes; + MultipleTextElement * + pServiceDependencies; }; - -class ModuleDescription : public ParentElement +class ComponentDescription : public SequenceElement { public: - typedef DynamicList<ComponentDescription> CD_List; - - void AddComponentDescription( - ComponentDescription & - let_drCD ); - - const char * Name() const { return Children()[0]->Data(); } - const CD_List & Components() const { return aCDs; } - + ComponentDescription(); + + const Simstr & ComponentName() const { return pComponentName->Data(); } + const MultipleTextElement & + SupportedServices() const + { return *pSupportedServices; } + const MultipleTextElement & + Types() const { return *pTypes; } + const MultipleTextElement & + ServiceDependencies() const + { return *pServiceDependencies; } private: - CD_List aCDs; + SglTextElement * pComponentName; + MultipleTextElement * + pSupportedServices; + MultipleTextElement * + pTypes; + MultipleTextElement * + pServiceDependencies; }; - -class ComponentDescription : public ParentElement +class CompDescrList : public ListElement { public: - typedef DynamicList<ReferenceDocuElement> Docu_List; - - void SetStatus( - const char * i_sText ); - - const char * Name() const { return Children()[0]->Data(); } - const Docu_List & DocuRefs() const { return aDocuRefs; } - Docu_List & DocuRefs() { return aDocuRefs; } - const char * Status() const { return sStatus; } - + CompDescrList(); + virtual void Write2Html( + HtmlCreator & io_rHC ) const; + virtual XmlElement * + Create_and_Add_NewElement(); + + void Get_SupportedServices( + List< const MultipleTextElement * > & + o_rResult ) const; + void Get_Types( + List< const MultipleTextElement * > & + o_rResult ) const; + void Get_ServiceDependencies( + List< const MultipleTextElement * > & + o_rResult ) const; private: - Simstr sStatus; - Docu_List aDocuRefs; + List< ComponentDescription * > + aCDs; }; - -class SglTextElement : public TextElement +class MdName : public SglTextElement { public: - SglTextElement( - const char * i_sName ); - virtual void SetText( - const char * i_sText ); - - virtual const char * - Name() const; - virtual const char * - Data( - unsigned i_nNr = 0 ) const; - virtual unsigned Size() const; - - private: - Simstr sName; - Simstr sContent; + MdName(); + virtual void Write2Html( + HtmlCreator & io_rHC ) const; }; - -class MultipleTextElement : public TextElement +class CdName : public SglTextElement { public: - MultipleTextElement( - const char * i_sName ); - virtual void SetText( - const char * i_sText ); - - virtual const char * - Name() const; - virtual const char * - Data( - unsigned i_nNr = 0 ) const; - virtual unsigned Size() const; - - private: - Simstr sName; - List<Simstr> aContent; + CdName(); + virtual void Write2Html( + HtmlCreator & io_rHC ) const; }; - -class ReferenceDocuElement +class SupportedService : public MultipleTextElement { public: + SupportedService(); - Simstr sAttr_href; - Simstr sAttr_role; - Simstr sAttr_title; + virtual void Insert2Index( + Index & o_rIndex ) const; }; + // IMPLEMENTATION |