Allow tag <type> in module-description

This commit is contained in:
Nikolai Pretzell
2001-03-23 12:24:04 +00:00
parent e566db9b51
commit 00c8e75bc9
24 changed files with 999 additions and 974 deletions

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: cmdline.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: cmdline.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: heap.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: heap.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: list.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $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 # The Contents of this file are made available subject to the terms of
# either of the following licenses # either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: sistr.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -671,7 +671,7 @@ Simstr::is_no_text() const
return true; return true;
int i; 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) if (i < len)
return false; return false;
return true; return true;

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: sistr.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: syshelp.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -66,13 +66,26 @@
// NOT FULLY DEFINED SERVICES // NOT FULLY DEFINED SERVICES
#include <string.h> #include <string.h>
#include "sistr.hxx" #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[] = "&nbsp;&nbsp;&nbsp;"; char C_sSpaceInName[] = "&nbsp;&nbsp;&nbsp;";
void void
WriteName( std::ofstream & o_rFile, WriteName( ofstream & o_rFile,
const Simstr & i_rIdlDocuBaseDir, const Simstr & i_rIdlDocuBaseDir,
const Simstr & i_rName, const Simstr & i_rName,
E_LinkType i_eLinkType ) E_LinkType i_eLinkType )
@@ -89,7 +102,7 @@ WriteName( std::ofstream & o_rFile,
if ( pNameEnd != 0 ) if ( pNameEnd != 0 )
{ {
const char * pStart = i_rName.str(); 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, C_sSpaceInName );
WriteStr( o_rFile, pNameEnd ); WriteStr( o_rFile, pNameEnd );
} }
@@ -189,3 +202,150 @@ WriteStr( std::ofstream & o_rFile,
o_rFile.write( i_sStr.str(), i_sStr.l() ); 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
}

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: syshelp.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -71,7 +71,7 @@
#include <fstream> #include <fstream>
class Simstr; class Simstr;
template <class XY> class List;
#ifdef WNT #ifdef WNT
@@ -106,6 +106,14 @@ void WriteStr(
std::ofstream & o_rFile, std::ofstream & o_rFile,
const Simstr & i_sStr ); 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 #endif

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: cr_html.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -87,14 +87,14 @@ char C_sHtmlFileFoot[] = "</BODY>\n</HTML>\n";
HtmlCreator::HtmlCreator( const char * i_pOutputFileName, HtmlCreator::HtmlCreator( const char * i_pOutputFileName,
const ModuleDescription & i_rDescr, const XmlElement & i_rDocument,
const Simstr & i_sIDL_BaseDirectory ) const Simstr & i_sIDL_BaseDirectory )
: aFile(i_pOutputFileName, ios::out : aFile(i_pOutputFileName, ios::out
#ifdef WNT #ifdef WNT
| ios::binary | ios::binary
#endif #endif
), ),
rDescr(i_rDescr), rDocument(i_rDocument),
sIdl_BaseDirectory(i_sIDL_BaseDirectory) sIdl_BaseDirectory(i_sIDL_BaseDirectory)
{ {
if ( !aFile ) if ( !aFile )
@@ -116,147 +116,16 @@ HtmlCreator::Run()
WriteStr( "ModuleDescription" ); WriteStr( "ModuleDescription" );
WriteStr( C_sHtmlFileHeader2 ); WriteStr( C_sHtmlFileHeader2 );
StartTable(); rDocument.Write2Html(*this);
const ParentElement::ChildList & rModuleElements = rDescr.Children();
unsigned i_max = rModuleElements.size();
for (unsigned i = 0; i < i_max; i++)
{
Write_TextElement( *rModuleElements[i], lt_nolink ); // Name,
// ProjectBuildDependency,
// RuntimeModuleDependency
} // end for
WriteStr( "<TR><TD COLSPAN=2>\n"
"<H4><BR>Components</H4>\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" );
Write_Description( *rCDs[d] );
} // end for
WriteStr( "</TD><TR>\n" );
FinishTable();
WriteStr( "<P><BR><BR></P>\n" ); WriteStr( "<P><BR><BR></P>\n" );
WriteStr( C_sHtmlFileFoot ); WriteStr( C_sHtmlFileFoot );
} }
void
HtmlCreator::Write_Description( const ComponentDescription & i_rDescr )
{
StartTable();
const ParentElement::ChildList & rDescrElements = i_rDescr.Children();
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
Write_Status(i_rDescr.Status()); // Status
for (unsigned i = 5; i < i_max; i++)
{
Write_TextElement( *rDescrElements[i], lt_idl ); // Supported Service,
// Service Dependency,
// Type
} // end for
const ComponentDescription::Docu_List & rDocuRefs = i_rDescr.DocuRefs();
unsigned r_max = rDocuRefs.size();
for (unsigned r = 0; r < r_max; r++)
{
Write_ReferenceDocu(*rDocuRefs[r]);
} // end for
FinishTable();
}
void
HtmlCreator::Write_TextElement( TextElement & i_rElement,
E_LinkType i_eLinkType )
{
StartRow();
WriteElementName( i_rElement );
WriteElementData( i_rElement, i_eLinkType );
FinishRow();
}
void
HtmlCreator::Write_ReferenceDocu( const ReferenceDocuElement & i_rRefDocu )
{
StartRow();
StartCell( "23%" );
WriteStr("ReferenceDocu");
FinishCell();
StartCell( "77%" );
if ( i_rRefDocu.sAttr_href.l() > 0)
{
WriteStr("<A href=\"http://");
WriteStr(i_rRefDocu.sAttr_href.str());
WriteStr("\">");
WriteStr(i_rRefDocu.sAttr_href.str());
WriteStr("</A><BR>\n");
}
if ( i_rRefDocu.sAttr_title.l() > 0)
{
WriteStr("Title: ");
WriteStr(i_rRefDocu.sAttr_title.str());
WriteStr("<BR>\n");
}
if ( i_rRefDocu.sAttr_role.l() > 0)
{
WriteStr("Role: ");
WriteStr(i_rRefDocu.sAttr_role.str());
}
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)
{
static char sH1a[] = "<H1 ALIGN=CENTER>";
static char sH1e[] = "</H1>";
WriteStr(sH1a);
WriteStr(i_pText);
WriteStr(sH1e);
}
void void
HtmlCreator::StartTable() HtmlCreator::StartTable()
{ {
WriteStr( "<P><BR></P>\n" );
WriteStr( WriteStr(
"<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 CELLPADDING=4>\n" "<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 CELLPADDING=4>\n"
" <TBODY>\n" ); " <TBODY>\n" );
@@ -269,6 +138,140 @@ HtmlCreator::FinishTable()
"</TABLE>\n\n" ); "</TABLE>\n\n" );
} }
void
HtmlCreator::StartBigCell( const char * i_sTitle )
{
WriteStr( "<TR><TD COLSPAN=2>\n"
"<H4><BR>" );
WriteStr( i_sTitle );
WriteStr( "</H4>\n" );
}
void
HtmlCreator::FinishBigCell()
{
WriteStr( "</TD><TR>\n" );
}
void
HtmlCreator::Write_SglTextElement( const SglTextElement & i_rElement,
bool i_bStrong )
{
StartRow();
WriteElementName( i_rElement.Name(), i_bStrong );
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( "\">" );
}
WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(),
i_bStrong ? lt_nolink : i_rElement.LinkType() );
if (i_bStrong)
WriteStr( "</A></H4>" );
FinishCell();
FinishRow();
}
void
HtmlCreator::Write_MultiTextElement( const MultipleTextElement & i_rElement )
{
StartRow();
WriteElementName( i_rElement.Name(), false );
StartCell( "77%");
unsigned i_max = i_rElement.Size();
for ( unsigned i = 0; i < i_max; ++i )
{
if (i > 0)
WriteStr( "<BR>\n" );
WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(i), i_rElement.LinkType() );
} // end for
FinishCell();
FinishRow();
}
void
HtmlCreator::Write_SglText( const Simstr & i_sName,
const Simstr & i_sValue )
{
StartRow();
WriteElementName( i_sName, false );
StartCell( "77%");
WriteStr( i_sValue );
FinishCell();
FinishRow();
}
void
HtmlCreator::Write_ReferenceDocu( const Simstr & i_sName,
const Simstr & i_sRef,
const Simstr & i_sRole,
const Simstr & i_sTitle )
{
StartRow();
StartCell( "23%" );
WriteStr(i_sName);
FinishCell();
StartCell( "77%" );
if ( !i_sRef.is_empty() )
{
WriteStr("<A href=\"");
WriteStr(i_sRef);
WriteStr("\">");
if ( !i_sTitle.is_empty() )
WriteStr( i_sTitle );
else
WriteStr(i_sRef);
WriteStr("</A><BR>\n");
}
else if ( !i_sTitle.is_empty() )
{
WriteStr("Title: ");
WriteStr( i_sTitle );
WriteStr("<BR>\n");
}
if ( !i_sRole.is_empty() )
{
WriteStr("Role: ");
WriteStr( i_sRole );
}
FinishCell();
FinishRow();
}
void
HtmlCreator::PrintH1( char * i_pText)
{
static char sH1a[] = "<H1 ALIGN=CENTER>";
static char sH1e[] = "</H1>";
WriteStr(sH1a);
WriteStr(i_pText);
WriteStr(sH1e);
}
void void
HtmlCreator::StartRow() HtmlCreator::StartRow()
{ {
@@ -296,62 +299,17 @@ HtmlCreator::FinishCell()
} }
void void
HtmlCreator::WriteElementName( TextElement & i_rElement ) HtmlCreator::WriteElementName( const Simstr & i_sName,
bool i_bStrong )
{ {
StartCell( "23%" ); StartCell( "23%" );
const char * pName = i_rElement.Name(); if (i_bStrong)
bool bStrong = strcmp(pName,"name") == 0 || strcmp(pName,"module-name") == 0;
if (bStrong)
WriteStr( "<H4>" ); WriteStr( "<H4>" );
WriteStr(pName); WriteStr(i_sName);
if (bStrong) if (i_bStrong)
WriteStr( "</H4>" ); WriteStr( "</H4>" );
FinishCell(); 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();
}

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: cr_html.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -69,10 +69,9 @@
#include "../support/syshelp.hxx" #include "../support/syshelp.hxx"
class ModuleDescription; class XmlElement;
class ComponentDescription; class SglTextElement;
class TextElement; class MultipleTextElement;
class ReferenceDocuElement;
class HtmlCreator class HtmlCreator
@@ -80,49 +79,51 @@ class HtmlCreator
public: public:
HtmlCreator( HtmlCreator(
const char * i_pOutputFileName, const char * i_pOutputFileName,
const ModuleDescription & const XmlElement & i_rDocument,
i_rDescr,
const Simstr & i_sIDL_BaseDirectory ); const Simstr & i_sIDL_BaseDirectory );
~HtmlCreator(); ~HtmlCreator();
void Run(); 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: private:
void PrintH1( void PrintH1(
char * i_pText ); char * i_pText );
void StartTable();
void FinishTable();
void StartRow(); void StartRow();
void FinishRow(); void FinishRow();
void StartCell( void StartCell(
char * i_pWidth ); char * i_pWidth );
void FinishCell(); 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( void WriteElementName(
TextElement & i_rElement ); const Simstr & i_sName,
void WriteElementData( bool i_bStrong );
TextElement & i_rElement,
E_LinkType i_eLinkType );
void WriteStr( void WriteStr(
const char * i_sStr ) const char * i_sStr )
{ aFile.write( i_sStr, strlen(i_sStr) ); } { aFile.write( i_sStr, strlen(i_sStr) ); }
// DATA // DATA
ofstream aFile; ofstream aFile;
const ModuleDescription & const XmlElement & rDocument;
rDescr;
Simstr sIdl_BaseDirectory; Simstr sIdl_BaseDirectory;
}; };

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: cr_index.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -72,6 +72,7 @@
using std::cerr; using std::cerr;
using std::ofstream; using std::ofstream;
extern unsigned C_nSupportedServicesIndex;
char C_sLineEnd[] = "\n"; char C_sLineEnd[] = "\n";
@@ -84,83 +85,26 @@ char C_sModule[] = "ModuleName";
char C_sComponentname[] = "ComponentName"; char C_sComponentname[] = "ComponentName";
int NrOfTagName(const char * i_sName);
Simstr sIdlRootPath; 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, Index::Index( const char * i_sOutputDirectory,
const char * i_sIdlRootPath, const char * i_sIdlRootPath,
const List<Simstr> & i_rTagList ) const List<Simstr> & i_rTagList )
: aService2Module(20), : aService2Module(20),
aModule2Service(20), aModule2Service(20),
aTagIndices(i_rTagList),
sOutputDirectory(i_sOutputDirectory), sOutputDirectory(i_sOutputDirectory),
sIdlRootPath(i_sIdlRootPath) sIdlRootPath(i_sIdlRootPath)
// sCurModule
{ {
::sIdlRootPath = i_sIdlRootPath; ::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::~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 void
Index::GatherData( const List<Simstr> & i_rInputFileList ) Index::GatherData( const List<Simstr> & i_rInputFileList )
{ {
@@ -192,16 +136,17 @@ Index::WriteOutput( const char * i_sOuputFile )
WriteTableFromHeap( aOut, aService2Module, C_sService, C_sModule, lt_html ); WriteTableFromHeap( aOut, aService2Module, C_sService, C_sModule, lt_html );
WriteTableFromHeap( aOut, aModule2Service, C_sModule, C_sService, lt_idl ); 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 ); WriteStr( aOut, C_sFileEnd );
aOut.close(); aOut.close();
} }
void
Index::InsertSupportedService( const Simstr & i_sService )
{
aService2Module.InsertValue( i_sService, sCurModule );
aModule2Service.InsertValue( sCurModule, i_sService );
}
void void
Index::ReadFile( const char * i_sFilename ) Index::ReadFile( const char * i_sFilename )
{ {
@@ -210,7 +155,9 @@ Index::ReadFile( const char * i_sFilename )
ModuleDescription aModule; ModuleDescription aModule;
X2CParser aParser(aModule); X2CParser aParser(aModule);
if ( ! aParser.Parse(i_sFilename) ) // Parse
bool bResult = aParser.Parse(i_sFilename);
if (! bResult)
{ {
cerr << "Error: File \"" cerr << "Error: File \""
<< i_sFilename << i_sFilename
@@ -225,67 +172,15 @@ Index::ReadFile( const char * i_sFilename )
aHtmlCreator.Run(); aHtmlCreator.Run();
// GetResults: // GetResults:
Simstr sModuleName = aModule.Name(); sCurModule = aModule.ModuleName();
// Module Tags List< const MultipleTextElement* > aSupportedServices;
const ModuleDescription::ChildList & aModule.Get_SupportedServices(aSupportedServices);
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
// Component Tags for ( unsigned s = 0; s < aSupportedServices.size(); ++s )
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;
for ( unsigned cd = 0; cd < rCDs.size(); ++cd )
{ {
const ComponentDescription::ChildList & aSupportedServices[s]->Insert2Index(*this);
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
} }
void void
@@ -300,13 +195,13 @@ Index::CreateHtmlFileName( char * o_sOutputHtml,
#else #else
#error WNT or UNX have to be defined. #error WNT or UNX have to be defined.
#endif #endif
strcat( o_sOutputHtml, i_rModule.Name() ); strcat( o_sOutputHtml, i_rModule.ModuleName() );
strcat( o_sOutputHtml, ".html" ); strcat( o_sOutputHtml, ".html" );
} }
void void
WriteTableFromHeap( ofstream & o_rOut, Index::WriteTableFromHeap( ofstream & o_rOut,
Heap & i_rHeap, Heap & i_rHeap,
const char * i_sIndexValue, const char * i_sIndexValue,
const char * i_sIndexReference, const char * i_sIndexReference,
@@ -325,7 +220,7 @@ WriteTableFromHeap( ofstream & o_rOut,
void void
WriteHeap( ofstream & o_rOut, Index::WriteHeap( ofstream & o_rOut,
Heap & i_rHeap, Heap & i_rHeap,
E_LinkType i_eLinkType ) E_LinkType i_eLinkType )
{ {
@@ -373,58 +268,6 @@ WriteHeap( ofstream & o_rOut,
WriteStr( o_rOut, "</TD></TR>\n" ); 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;
}
/** <20>bersicht der Struktur /** <20>bersicht der Struktur
@@ -447,6 +290,9 @@ MODULEDESCRIPTION
} }
ProjectBuildDependency* ProjectBuildDependency*
RuntimeModuleDependency* RuntimeModuleDependency*
ReferenceDocu*
ServiceDependency*
Type*
} }

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: cr_index.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -65,9 +65,9 @@
#include "../support/sistr.hxx" #include "../support/sistr.hxx"
#include "../support/heap.hxx" #include "../support/heap.hxx"
#include "../support/list.hxx" #include "../support/list.hxx"
#include "../support/syshelp.hxx"
const unsigned C_nNrOfTagNames = 8;
class ModuleDescription; class ModuleDescription;
@@ -87,40 +87,35 @@ class Index
void WriteOutput( void WriteOutput(
const char * i_sOuputFile ); const char * i_sOuputFile );
void InsertSupportedService(
const Simstr & i_sService );
private: 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( void ReadFile(
const char * i_sFilename ); const char * i_sFilename );
void CreateHtmlFileName( void CreateHtmlFileName(
char * o_sOutputHtml, char * o_sOutputHtml,
const ModuleDescription & const ModuleDescription &
i_rModule ); 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 aService2Module;
Heap aModule2Service; Heap aModule2Service;
IndexedTags aTagIndices;
Simstr sOutputDirectory; Simstr sOutputDirectory;
Simstr sIdlRootPath; Simstr sIdlRootPath;
// Temporary Data
Simstr sCurModule;
}; };

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: cr_metho.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * 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" char C_sFuncBegin[] = "#ifdef __cplusplus\r\n"
"extern \"C\" {\r\n" "extern \"C\" {\r\n"
"#endif\r\n\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" "{\r\n"
" return (sal_Char*) \r\n" " return (sal_Char*) \r\n"
" \""; " \"";

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: cr_metho.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: filebuff.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: filebuff.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: main.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -68,37 +68,22 @@
#include "cr_metho.hxx" #include "cr_metho.hxx"
#include "cr_html.hxx" #include "cr_html.hxx"
#include "cr_index.hxx" #include "cr_index.hxx"
#include "xmlelem.hxx"
#include "xmltree.hxx" #include "xmltree.hxx"
#include "parse.hxx" #include "parse.hxx"
#include "../support/syshelp.hxx" #include "../support/syshelp.hxx"
#include "../support/heap.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( int Do_IndexCommandLine(
const CommandLine & i_rCommandLine ); const CommandLine & i_rCommandLine );
int Do_SingleFileCommandLine( int Do_SingleFileCommandLine(
const CommandLine & i_rCommandLine ); 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( void Create_TypeInfoFile(
const char * o_sOutputFile, const char * o_sOutputFile,
ModuleDescription & i_rData ); ModuleDescription & i_rData );
@@ -117,7 +102,7 @@ main( int argc,
if (! aCommandLine.IsOk()) if (! aCommandLine.IsOk())
{ {
cerr << aCommandLine.ErrorText() << std::endl; cerr << aCommandLine.ErrorText() << endl;
return 1; return 1;
} }
@@ -136,20 +121,30 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
ModuleDescription aDescr; ModuleDescription aDescr;
X2CParser aParser(aDescr); X2CParser aParser(aDescr);
// Parse // Load file and create Function-file
bool bParseResult = aParser.Parse(i_rCommandLine.XmlSrcFile()); bool bLoadResult = aParser.LoadFile(i_rCommandLine.XmlSrcFile());
if (! bParseResult) 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; return 1;
} }
// Produce output
if ( strlen(i_rCommandLine.FuncFile()) > 0 ) if ( strlen(i_rCommandLine.FuncFile()) > 0 )
{ {
Create_AccessMethod( i_rCommandLine.FuncFile(), Create_AccessMethod( i_rCommandLine.FuncFile(),
aParser.PureText() ); 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 ) if ( strlen(i_rCommandLine.HtmlFile()) > 0 )
{ {
HtmlCreator aHtmlCreator( i_rCommandLine.HtmlFile(), HtmlCreator aHtmlCreator( i_rCommandLine.HtmlFile(),
@@ -176,162 +171,19 @@ Do_IndexCommandLine(const CommandLine & i_rCommandLine)
i_rCommandLine.IdlRootPath(), i_rCommandLine.IdlRootPath(),
i_rCommandLine.IndexedTags() ); i_rCommandLine.IndexedTags() );
std::cout << "Gather xml-files ..." << std::endl; std::cout << "Gather xml-files ..." << endl;
GatherFileNames( aFiles, i_rCommandLine.XmlSrcDirectory() ); GatherFileNames( aFiles, i_rCommandLine.XmlSrcDirectory() );
std::cout << "Create output ..." << std::endl; std::cout << "Create output ..." << endl;
aIndex.GatherData(aFiles); aIndex.GatherData(aFiles);
aIndex.WriteOutput( i_rCommandLine.IndexOutputFile() ); aIndex.WriteOutput( i_rCommandLine.IndexOutputFile() );
std::cout << "... done." << std::endl; std::cout << "... done." << endl;
return 0; 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 void
Create_TypeInfoFile( const char * o_sOutputFile, Create_TypeInfoFile( const char * o_sOutputFile,
@@ -344,39 +196,25 @@ Create_TypeInfoFile( const char * o_sOutputFile,
); );
if ( !aOut ) if ( !aOut )
{ {
cerr << "Error: " << o_sOutputFile << " could not be created." << std::endl; cerr << "Error: " << o_sOutputFile << " could not be created." << endl;
return; return;
} }
Heap aTypesHeap(12); Heap aTypesHeap(12);
Simstr sLibPrefix = i_rData.Children()[0]->Data(); Simstr sLibPrefix = i_rData.ModuleName();
// Gather types: // Gather types:
const ModuleDescription::CD_List & rListDescriptions = i_rData.Components(); List< const MultipleTextElement * > aTypes;
i_rData.Get_Types(aTypes);
// Descriptions: for ( unsigned t = 0; t < aTypes.size(); ++t )
for ( unsigned nDescrIter = 0; nDescrIter < rListDescriptions.size(); ++nDescrIter )
{ {
// Find Type-Tag: unsigned i_max = aTypes[t]->Size();
TextElement * pTypes = 0; for ( unsigned i = 0; i < i_max; ++i )
ComponentDescription::ChildList & rTags = rListDescriptions[nDescrIter]->Children();
for ( unsigned nTagIter = 0; nTagIter < rTags.size(); ++nTagIter )
{ {
if ( strcmp( rTags[nTagIter]->Name(),"type") == 0 ) aTypesHeap.InsertValue( aTypes[t]->Data(i), "" );
{ } // end for
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)
// Write types: // Write types:
WriteStr( aOut, sLibPrefix ); WriteStr( aOut, sLibPrefix );

View File

@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $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 # The Contents of this file are made available subject to the terms of
# either of the following licenses # either of the following licenses
@@ -76,13 +76,26 @@ TARGETTYPE=CUI
# --- Files -------------------------------------------------------- # --- Files --------------------------------------------------------
OBJFILES= \ LIB1TARGET=$(LB)$/$(TARGET).lib
LIB1OBJFILES=\
$(OBJ)$/main.obj \ $(OBJ)$/main.obj \
$(OBJ)$/cr_html.obj \ $(OBJ)$/cr_html.obj \
$(OBJ)$/cr_index.obj \ $(OBJ)$/cr_index.obj \
$(OBJ)$/cr_metho.obj \ $(OBJ)$/cr_metho.obj \
$(OBJ)$/filebuff.obj \ $(OBJ)$/filebuff.obj \
$(OBJ)$/parse.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 $(OBJ)$/xmltree.obj
@@ -90,6 +103,7 @@ OBJFILES= \
# --- Targets ------------------------------------------------------ # --- Targets ------------------------------------------------------
.INCLUDE : target.mk .INCLUDE : target.mk

View File

@@ -2,7 +2,7 @@
* *
* $RCSfile: parse.cxx,v $ * $RCSfile: parse.cxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: np $Date: $ * last change: $Author: np $Date: $
* *
@@ -64,45 +64,31 @@
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
#include <xmltree.hxx> #include <xmlelem.hxx>
#ifdef UNX #ifdef UNX
#define strnicmp strncasecmp #define strnicmp strncasecmp
#endif #endif
using std::cerr; using namespace std;
// NOT FULLY DEFINED SERVICES // 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) \ #define AssertionOf(x) \
{if (!(x)) {cerr << "Assertion failed: " << #x << __FILE__ << __LINE__ << std::endl; exit(3); }} {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 ) X2CParser::X2CParser( XmlElement & o_rDocumentData )
: pData(&o_rData) : // sFileName,
nFileLine(0),
pDocumentData(&o_rDocumentData),
// sWord,
text(0)
{ {
} }
@@ -110,9 +96,13 @@ X2CParser::~X2CParser()
{ {
} }
bool bool
X2CParser::Parse( const char * i_sFilename ) X2CParser::LoadFile( const char * i_sFilename )
{ {
sFileName = i_sFilename;
nFileLine = 1;
// Load file: // Load file:
if ( ! LoadXmlFile( aFile, i_sFilename ) ) if ( ! LoadXmlFile( aFile, i_sFilename ) )
return false; return false;
@@ -121,20 +111,33 @@ X2CParser::Parse( const char * i_sFilename )
const char * pLastTag = strrchr(aFile.operator const char *(),'<'); const char * pLastTag = strrchr(aFile.operator const char *(),'<');
if (pLastTag == 0) if (pLastTag == 0)
return false; 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 ) || strnicmp(pLastTag, "</", 2) != 0 )
return false; return false;
if (strchr(pLastTag,'>') == 0) if (strchr(pLastTag,'>') == 0)
return false; return false;
return true;
}
void
X2CParser::Parse()
{
// Parse: // Parse:
text = aFile.operator const char *(); text = aFile.operator const char *();
Parse_XmlDeclaration(); Parse_XmlDeclaration();
Parse_Doctype(); 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 void
@@ -156,176 +159,149 @@ X2CParser::Parse_Doctype()
} }
void void
X2CParser::Parse_ModuleDescription() X2CParser::Parse_Sequence( DynamicList<XmlElement> & o_rElements,
const Simstr & i_sElementName )
{ {
Goto('<'); CheckAndPassBeginTag(i_sElementName.str());
AssertionOf( IsBeginTag(C_sMODULEDESCRIPTION) );
Goto_And_Pass('>');
Parse_TextElement(C_sModuleName,*pData, true, false); unsigned int i_max = o_rElements.size();
for (unsigned i = 0; i < i_max; ++i)
for ( Goto('<');
IsBeginTag(C_sCOMPONENTDESCRIPTION);
Goto('<') )
{ {
Parse_ComponentDescription(*pData); o_rElements[i]->Parse(*this);
} } // end for
for ( ; ! IsEndTag(C_sMODULEDESCRIPTION); Goto('<') ) CheckAndPassEndTag(i_sElementName.str());
{
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('>');
} }
void void
X2CParser::Parse_ComponentDescription(ModuleDescription & o_rParent) X2CParser::Parse_FreeChoice( DynamicList<XmlElement> & o_rElements )
{ {
unsigned nSize = o_rElements.size();
for ( bool bBreak = false; !bBreak; )
{
bBreak = true;
for ( unsigned i = 0; i < nSize; ++i )
{
Goto('<'); Goto('<');
AssertionOf( IsBeginTag(C_sCOMPONENTDESCRIPTION) ); if ( IsBeginTag(o_rElements[i]->Name().str()) )
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); o_rElements[i]->Parse(*this);
bBreak = false;
break;
} }
} // end for i
for ( Goto('<'); } // end for !bBreak
! IsEndTag(C_sCOMPONENTDESCRIPTION);
Goto('<') )
{
if ( IsBeginTag(C_sReferenceDocu) )
{
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;
} }
void void
X2CParser::Parse_ReferenceDocu(ReferenceDocuElement & o_rElement) X2CParser::Parse_List( ListElement & o_rListElem )
{ {
Move( strlen(C_sReferenceDocu) + 1 );
for ( Goto('<'); IsBeginTag(o_rListElem.Name().str()); Goto('<') )
{
XmlElement * pNew = o_rListElem.Create_and_Add_NewElement();
pNew->Parse(*this);
}
}
void
X2CParser::Parse_Text( Simstr & o_sText,
const Simstr & i_sElementName,
bool i_bReverseName )
{
CheckAndPassBeginTag(i_sElementName.str());
// Add new Element
GetTextTill( o_sText, '<', i_bReverseName );
o_sText.remove_trailing_blanks();
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('<') )
{
o_rTexts.push_back(Simstr());
Parse_Text(o_rTexts.back(), i_sElementName, i_bReverseName);
}
}
void
X2CParser::Parse_SglAttr( Simstr & o_sAttrValue,
const Simstr & i_sElementName,
const Simstr & i_sAttrName )
{
Goto('<');
if ( !IsBeginTag(i_sElementName.str()) )
SyntaxError("unexpected element");
Move( i_sElementName.l() + 1 );
Pass_White();
if (*text == '>')
SyntaxError("no attribute found, where one was expected");
Simstr sAttrName;
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::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;
unsigned nSize = i_rAttrNames.size();
for ( Pass_White(); *text != '/'; Pass_White() ) for ( Pass_White(); *text != '/'; Pass_White() )
{ {
Get_ReferenceDocuAttribute(o_rElement);
}
Move(1);
}
void Get_Attribute(sAttrValue, sAttrName);
X2CParser::Parse_TextElement( const char * i_sElementName,
ParentElement & o_rParent,
bool i_bSingle,
bool i_bReverseName )
{
Goto('<');
text++;
AssertionOf( IsText(i_sElementName) );
Goto_And_Pass('>');
Pass_White();
TextElement * pNew = 0; for ( unsigned i = 0; i < nSize; ++i )
if ( !i_bSingle && o_rParent.Children().size() > 0 )
{ {
if ( strcmp( o_rParent.Children().back()->Name(), if ( i_rAttrNames[i] == sAttrName )
i_sElementName ) == 0 )
{ {
pNew = o_rParent.Children().back(); o_rAttrValues[i] = sAttrValue;
break;
} }
} }
if (pNew == 0) if (i == nSize)
{ SyntaxError("unknown attribute found");
pNew = i_bSingle
? (TextElement*) new SglTextElement(i_sElementName)
: (TextElement*) new MultipleTextElement(i_sElementName);
o_rParent.AddChild(*pNew);
} }
// 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 )
{
Goto('<');
AssertionOf( IsBeginTag(C_sStatus) );
Move( strlen(C_sStatus) + 1 );
Pass_White();
AssertionOf(*text != '>');
Simstr sAttrName;
Simstr sAttrValue = Get_Attribute(sAttrName);
o_rParent.SetStatus(sAttrValue);
Move(2); Move(2);
} }
void
X2CParser::Get_ReferenceDocuAttribute( ReferenceDocuElement & o_rElement )
{
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 void
X2CParser::Get_Attribute( Simstr & o_rAttrName ) X2CParser::Get_Attribute( Simstr & o_rAttrValue,
Simstr & o_rAttrName )
{ {
GetTextTill( o_rAttrName, '='); GetTextTill( o_rAttrName, '=');
while (*(++text) != '"') while (*(++text) != '"')
{ {
AssertionOf(*text != '\0'); if (*text == '\0')
SyntaxError("unexpected end of file");
} }
++text; ++text;
Simstr ret; GetTextTill( o_rAttrValue, '"');
GetTextTill( ret, '"');
++text; ++text;
return ret;
} }
bool bool
@@ -353,8 +329,8 @@ X2CParser::Goto( char i_cNext )
{ {
while (*text != i_cNext) while (*text != i_cNext)
{ {
TestCurChar();
++text; ++text;
AssertionOf(*text != '\0');
} }
} }
@@ -376,8 +352,8 @@ X2CParser::Pass_White()
{ {
while (*text <= 32) while (*text <= 32)
{ {
TestCurChar();
++text; ++text;
AssertionOf(*text != '\0');
} }
} }
@@ -392,7 +368,7 @@ X2CParser::GetTextTill( Simstr & o_rText,
*text != i_cEnd; *text != i_cEnd;
++text ) ++text )
{ {
AssertionOf(*text !='\0'); TestCurChar();
*pSet++ = *text; *pSet++ = *text;
} }
@@ -426,4 +402,50 @@ X2CParser::GetTextTill( Simstr & o_rText,
o_rText = &sWord[0]; 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++;
}

View File

@@ -2,7 +2,7 @@
* *
* $RCSfile: parse.hxx,v $ * $RCSfile: parse.hxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: np $Date: $ * last change: $Author: np $Date: $
* *
@@ -69,46 +69,64 @@
// COMPONENTS // COMPONENTS
#include "filebuff.hxx" #include "filebuff.hxx"
#include "../support/sistr.hxx" #include "../support/sistr.hxx"
#include "../support/list.hxx"
// PARAMETERS // PARAMETERS
class ModuleDescription; class XmlElement;
class ParentElement; class ListElement;
class ComponentDescription;
class ReferenceDocuElement;
class X2CParser class X2CParser
{ {
public: public:
typedef XmlElement * (*F_CREATE)(const Simstr &);
X2CParser( X2CParser(
ModuleDescription & o_rData ); XmlElement & o_rDocumentData );
~X2CParser(); ~X2CParser();
bool LoadFile(
const char * i_sFilename );
void Parse();
bool Parse( bool Parse(
const char * i_sFilename ); const char * i_sFilename );
const char * PureText() const { return aFile.operator const char*(); } 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: private:
void Parse_XmlDeclaration(); void Parse_XmlDeclaration();
void Parse_Doctype(); void Parse_Doctype();
void Parse_ModuleDescription();
void Parse_ComponentDescription( void Get_Attribute(
ModuleDescription & o_rParent ); Simstr & o_rAttrValue,
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 ); Simstr & o_rAttrName );
bool IsText( bool IsText(
const char * i_sComparedText ); const char * i_sComparedText );
@@ -127,10 +145,22 @@ class X2CParser
Simstr & o_rText, Simstr & o_rText,
char i_cEnd, char i_cEnd,
bool i_bReverseName = false ); 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 // DATA
Simstr sFileName;
unsigned nFileLine;
Buffer aFile; Buffer aFile;
ModuleDescription * pData; XmlElement * pDocumentData;
char sWord[8192]; char sWord[8192];
const char * text; const char * text;

View File

@@ -2,7 +2,7 @@
* *
* $RCSfile: xmltree.cxx,v $ * $RCSfile: xmltree.cxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: np $Date: $ * last change: $Author: np $Date: $
* *
@@ -64,86 +64,257 @@
// NOT FULLY DEFINED SERVICES // NOT FULLY DEFINED SERVICES
#include <cr_html.hxx>
#include <cr_index.hxx>
void char C_sMODULEDESCRIPTION[] = "module-description";
ParentElement::AddChild( TextElement & let_drElement ) 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)
{ {
aChildren.push_back(&let_drElement); pModuleName = new MdName;
AddChild( *pModuleName );
pCdList = new CompDescrList;
AddChild( *pCdList );
AddChild( *Create_ModuleDescrOptional_Element( pTypes, pServiceDependencies ) );
} }
const Simstr &
void ModuleDescription::ModuleName() const
ModuleDescription::AddComponentDescription( ComponentDescription & let_drCD )
{ {
aCDs.push_back(&let_drCD); return pModuleName->Data();
} }
void void
ComponentDescription::SetStatus( const char * i_sText ) ModuleDescription::Get_SupportedServices( List< const MultipleTextElement * > & o_rServices ) const
{ {
sStatus = i_sText; o_rServices.push_back(pServiceDependencies);
pCdList->Get_SupportedServices( o_rServices );
} }
SglTextElement::SglTextElement( const char * i_sName ) void
: sName(i_sName) 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 void
SglTextElement::SetText( const char * i_sText ) CompDescrList::Write2Html( HtmlCreator & io_rHC ) const
{ {
sContent = i_sText; io_rHC.StartBigCell(C_sCompDescrListTitle);
ListElement::Write2Html(io_rHC);
io_rHC.FinishBigCell();
} }
const char * XmlElement *
SglTextElement::Name() const CompDescrList::Create_and_Add_NewElement()
{ {
return sName; ComponentDescription * pCD = new ComponentDescription;
Children().push_back(pCD);
aCDs.push_back(pCD);
return pCD;
} }
const char * void
SglTextElement::Data( unsigned i_nNr ) const CompDescrList::Get_SupportedServices( List< const MultipleTextElement * > & o_rResult ) const
{ {
return sContent.str(); unsigned i_max = aCDs.size();;
for (unsigned i = 0; i < i_max; ++i)
{
o_rResult.push_back(& aCDs[i]->SupportedServices());
} // end for
} }
unsigned void
SglTextElement::Size() const CompDescrList::Get_Types( List< const MultipleTextElement * > & o_rResult ) const
{ {
return 1; unsigned i_max = aCDs.size();;
for (unsigned i = 0; i < i_max; ++i)
{
o_rResult.push_back(& aCDs[i]->Types());
} // end for
} }
void
CompDescrList::Get_ServiceDependencies( 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]->ServiceDependencies());
} // end for
}
MultipleTextElement::MultipleTextElement( const char * i_sName ) MdName::MdName()
: sName(i_sName) : SglTextElement(C_sModuleName, lt_html, false)
{ {
} }
void void
MultipleTextElement::SetText( const char * i_sText ) MdName::Write2Html( HtmlCreator & io_rHC ) const
{ {
aContent.push_back(i_sText); io_rHC.Write_SglTextElement( *this, true );
} }
const char * CdName::CdName()
MultipleTextElement::Name() const : SglTextElement(C_sName, lt_html, true)
{ {
return sName;
} }
const char * void
MultipleTextElement::Data( unsigned i_nNr ) const CdName::Write2Html( HtmlCreator & io_rHC ) const
{ {
if (i_nNr < aContent.size()) io_rHC.Write_SglTextElement( *this, true );
return aContent[i_nNr].str();
else
return "";
} }
unsigned SupportedService::SupportedService()
MultipleTextElement::Size() const : MultipleTextElement(C_sSupportedService, lt_idl, true)
{ {
return aContent.size();
} }
void
SupportedService::Insert2Index( Index & o_rIndex ) const
{
for ( unsigned i = 0; i < Size(); ++i )
{
o_rIndex.InsertSupportedService( Data(i) );
}
}
FreeChoiceElement *
Create_ModuleDescrOptional_Element( MultipleTextElement * & o_rTypes,
MultipleTextElement * & o_rServiceDependencies )
{
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;
}
FreeChoiceElement *
Create_CompDescrOptional_Element( MultipleTextElement * & o_rTypes,
MultipleTextElement * & o_rServiceDependencies )
{
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;
}
#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 *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

View File

@@ -2,7 +2,7 @@
* *
* $RCSfile: xmltree.hxx,v $ * $RCSfile: xmltree.hxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: np $Date: $ * last change: $Author: np $Date: $
* *
@@ -66,131 +66,113 @@
// USED SERVICES // USED SERVICES
// BASE CLASSES // BASE CLASSES
#include "xmlelem.hxx"
// COMPONENTS // COMPONENTS
#include "../support/sistr.hxx" #include "../support/sistr.hxx"
#include "../support/list.hxx" #include "../support/list.hxx"
// PARAMETERS // PARAMETERS
class ComponentDescription; class CompDescrList;
class ReferenceDocuElement;
class TextElement class ModuleDescription : public SequenceElement
{ {
public: public:
virtual void SetText( ModuleDescription();
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; }
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: private:
ChildList aChildren; SglTextElement * pModuleName;
CompDescrList * pCdList;
MultipleTextElement *
pTypes;
MultipleTextElement *
pServiceDependencies;
}; };
class ComponentDescription : public SequenceElement
class ModuleDescription : public ParentElement
{ {
public: public:
typedef DynamicList<ComponentDescription> CD_List; ComponentDescription();
void AddComponentDescription(
ComponentDescription &
let_drCD );
const char * Name() const { return Children()[0]->Data(); }
const CD_List & Components() const { return aCDs; }
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: private:
CD_List aCDs; SglTextElement * pComponentName;
MultipleTextElement *
pSupportedServices;
MultipleTextElement *
pTypes;
MultipleTextElement *
pServiceDependencies;
}; };
class CompDescrList : public ListElement
class ComponentDescription : public ParentElement
{ {
public: public:
typedef DynamicList<ReferenceDocuElement> Docu_List; CompDescrList();
virtual void Write2Html(
void SetStatus( HtmlCreator & io_rHC ) const;
const char * i_sText ); virtual XmlElement *
Create_and_Add_NewElement();
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; }
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: private:
Simstr sStatus; List< ComponentDescription * >
Docu_List aDocuRefs; aCDs;
}; };
class MdName : public SglTextElement
class SglTextElement : public TextElement
{ {
public: public:
SglTextElement( MdName();
const char * i_sName ); virtual void Write2Html(
virtual void SetText( HtmlCreator & io_rHC ) const;
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;
}; };
class CdName : public SglTextElement
class MultipleTextElement : public TextElement
{ {
public: public:
MultipleTextElement( CdName();
const char * i_sName ); virtual void Write2Html(
virtual void SetText( HtmlCreator & io_rHC ) const;
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;
}; };
class SupportedService : public MultipleTextElement
class ReferenceDocuElement
{ {
public: public:
SupportedService();
Simstr sAttr_href; virtual void Insert2Index(
Simstr sAttr_role; Index & o_rIndex ) const;
Simstr sAttr_title;
}; };
// IMPLEMENTATION // IMPLEMENTATION