summaryrefslogtreecommitdiff
path: root/xml2cmp
diff options
context:
space:
mode:
authorNikolai Pretzell <np@openoffice.org>2001-07-10 10:02:30 +0000
committerNikolai Pretzell <np@openoffice.org>2001-07-10 10:02:30 +0000
commit1916b1bfec0c27d6ce5d1c3f574fe875f9671c37 (patch)
tree3ce6e11aa3fb5203784858f49c5913e57e912fc2 /xml2cmp
parent7931ce83db4033594834a403050dae76a3d6098d (diff)
allow type list to be put to stdout
Diffstat (limited to 'xml2cmp')
-rw-r--r--xml2cmp/source/support/syshelp.cxx10
-rw-r--r--xml2cmp/source/support/syshelp.hxx12
-rw-r--r--xml2cmp/source/xcd/cr_index.cxx10
-rw-r--r--xml2cmp/source/xcd/cr_index.hxx8
-rw-r--r--xml2cmp/source/xcd/main.cxx121
5 files changed, 134 insertions, 27 deletions
diff --git a/xml2cmp/source/support/syshelp.cxx b/xml2cmp/source/support/syshelp.cxx
index d04cd4380c8f..27305f37148e 100644
--- a/xml2cmp/source/support/syshelp.cxx
+++ b/xml2cmp/source/support/syshelp.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: syshelp.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $
+ * last change: $Author: np $ $Date: 2001-07-10 11:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -85,7 +85,7 @@ using namespace std;
char C_sSpaceInName[] = "&nbsp;&nbsp;&nbsp;";
void
-WriteName( ofstream & o_rFile,
+WriteName( ostream & o_rFile,
const Simstr & i_rIdlDocuBaseDir,
const Simstr & i_rName,
E_LinkType i_eLinkType )
@@ -189,14 +189,14 @@ WriteName( ofstream & o_rFile,
void
-WriteStr( std::ofstream & o_rFile,
+WriteStr( std::ostream & o_rFile,
const char * i_sStr )
{
o_rFile.write( i_sStr, strlen(i_sStr) );
}
void
-WriteStr( std::ofstream & o_rFile,
+WriteStr( std::ostream & o_rFile,
const Simstr & i_sStr )
{
o_rFile.write( i_sStr.str(), i_sStr.l() );
diff --git a/xml2cmp/source/support/syshelp.hxx b/xml2cmp/source/support/syshelp.hxx
index 7f9812ff5de9..427670e315d1 100644
--- a/xml2cmp/source/support/syshelp.hxx
+++ b/xml2cmp/source/support/syshelp.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: syshelp.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: np $ $Date: 2001-03-23 13:23:17 $
+ * last change: $Author: np $ $Date: 2001-07-10 11:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,7 +68,7 @@
// BASE CLASSES
// COMPONENTS
// PARAMETERS
-#include <fstream>
+#include <iostream>
class Simstr;
template <class XY> class List;
@@ -93,17 +93,17 @@ enum E_LinkType
void WriteName(
- std::ofstream & o_rFile,
+ std::ostream & o_rFile,
const Simstr & i_rIdlDocuBaseDir,
const Simstr & i_rName,
E_LinkType i_eLinkType );
void WriteStr(
- std::ofstream & o_rFile,
+ std::ostream & o_rFile,
const char * i_sStr );
void WriteStr(
- std::ofstream & o_rFile,
+ std::ostream & o_rFile,
const Simstr & i_sStr );
void GatherFileNames(
diff --git a/xml2cmp/source/xcd/cr_index.cxx b/xml2cmp/source/xcd/cr_index.cxx
index 0fe1fbf49a37..ad52ee4b3b07 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.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: np $ $Date: 2001-03-23 13:39:36 $
+ * last change: $Author: np $ $Date: 2001-07-10 11:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -201,8 +201,8 @@ Index::CreateHtmlFileName( char * o_sOutputHtml,
void
-Index::WriteTableFromHeap( ofstream & o_rOut,
- Heap & i_rHeap,
+Index::WriteTableFromHeap( ostream & o_rOut,
+ Heap & i_rHeap,
const char * i_sIndexValue,
const char * i_sIndexReference,
E_LinkType i_eLinkType )
@@ -220,7 +220,7 @@ Index::WriteTableFromHeap( ofstream & o_rOut,
void
-Index::WriteHeap( ofstream & o_rOut,
+Index::WriteHeap( ostream & o_rOut,
Heap & i_rHeap,
E_LinkType i_eLinkType )
{
diff --git a/xml2cmp/source/xcd/cr_index.hxx b/xml2cmp/source/xcd/cr_index.hxx
index dfc92e1db5e3..01636765ebce 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.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: np $ $Date: 2001-03-23 13:39:36 $
+ * last change: $Author: np $ $Date: 2001-07-10 11:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,13 +97,13 @@ class Index
const ModuleDescription &
i_rModule );
void WriteTableFromHeap(
- std::ofstream & o_rOut,
+ std::ostream & o_rOut,
Heap & i_rHeap,
const char * i_sIndexKey,
const char * i_sIndexReference,
E_LinkType i_eLinkType );
void WriteHeap(
- std::ofstream & o_rOut,
+ std::ostream & o_rOut,
Heap & i_rHeap,
E_LinkType i_eLinkType );
diff --git a/xml2cmp/source/xcd/main.cxx b/xml2cmp/source/xcd/main.cxx
index 8db73452f7e8..23804d0e8248 100644
--- a/xml2cmp/source/xcd/main.cxx
+++ b/xml2cmp/source/xcd/main.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: main.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: np $ $Date: 2001-03-23 13:39:36 $
+ * last change: $Author: np $ $Date: 2001-07-10 11:02:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,7 +84,7 @@ int Do_IndexCommandLine(
const CommandLine & i_rCommandLine );
int Do_SingleFileCommandLine(
const CommandLine & i_rCommandLine );
-void Create_TypeInfoFile(
+void Create_TypeInfo(
const char * o_sOutputFile,
ModuleDescription & i_rData );
@@ -155,8 +155,8 @@ Do_SingleFileCommandLine(const CommandLine & i_rCommandLine)
if (strlen(i_rCommandLine.TypeInfoFile()) > 0)
{
- Create_TypeInfoFile( i_rCommandLine.TypeInfoFile() ,
- aDescr );
+ Create_TypeInfo( i_rCommandLine.TypeInfoFile(),
+ aDescr );
}
return 0;
@@ -185,10 +185,32 @@ Do_IndexCommandLine(const CommandLine & i_rCommandLine)
+//******************** Creating of typeinfo ********************//
+
+
+void Put2StdOut_TypeInfo(
+ ModuleDescription & i_rData );
+void Put2File_TypeInfo(
+ const char * i_sOutputFile,
+ ModuleDescription & i_rData );
+void StreamOut_TypeInfo(
+ ostream & o_rOut,
+ ModuleDescription & i_rData,
+ const char * i_sSeparator );
+
+
+
+
void
-Create_TypeInfoFile( const char * o_sOutputFile,
- ModuleDescription & i_rData )
+Create_TypeInfo( const char * o_sOutputFile,
+ ModuleDescription & i_rData )
{
+ if ( strcmp(o_sOutputFile, "stdout") == 0 )
+ Put2StdOut_TypeInfo(i_rData);
+ else
+ Put2File_TypeInfo(o_sOutputFile,i_rData);
+
+#if 0
ofstream aOut(o_sOutputFile, ios::out
#ifdef WNT
| ios::binary
@@ -253,5 +275,90 @@ Create_TypeInfoFile( const char * o_sOutputFile,
}
aOut.close();
+#endif // 0
+}
+
+void
+Put2StdOut_TypeInfo( ModuleDescription & i_rData )
+{
+ StreamOut_TypeInfo(cout, i_rData, " ");
+}
+
+void
+Put2File_TypeInfo( const char * i_sOutputFile,
+ ModuleDescription & i_rData )
+{
+ ofstream aOut(i_sOutputFile, ios::out
+#ifdef WNT
+ | ios::binary
+#endif
+ );
+ if ( !aOut )
+ {
+ cerr << "Error: " << i_sOutputFile << " could not be created." << endl;
+ return;
+ }
+
+ Simstr sLibPrefix = i_rData.ModuleName();
+ WriteStr( aOut, sLibPrefix );
+ WriteStr( aOut, "_XML2CMPTYPES= ");
+
+ StreamOut_TypeInfo(aOut, i_rData, "\t\\\n\t\t");
+
+ aOut.close();
+}
+
+void
+StreamOut_TypeInfo( ostream & o_rOut,
+ ModuleDescription & i_rData,
+ const char * i_sSeparator )
+{
+ Heap aTypesHeap(12);
+
+ // Gather types:
+ List< const MultipleTextElement * > aTypes;
+ i_rData.Get_Types(aTypes);
+
+ for ( unsigned t = 0; t < aTypes.size(); ++t )
+ {
+ unsigned i_max = aTypes[t]->Size();
+ for ( unsigned i = 0; i < i_max; ++i )
+ {
+ aTypesHeap.InsertValue( aTypes[t]->Data(i), "" );
+ } // end for
+ }
+
+ // Write types:
+ HeapItem * pLastHeapTop = 0;
+ for ( HeapItem * pHeapTop = aTypesHeap.ReleaseTop(); pHeapTop != 0; pHeapTop = aTypesHeap.ReleaseTop() )
+ {
+ if (pLastHeapTop != 0)
+ {
+ if ( 0 == strcmp(pHeapTop->Key(), pLastHeapTop->Key()) )
+ continue;
+ delete pLastHeapTop;
+ // pLastHeapTop = 0;
+ }
+ pLastHeapTop = pHeapTop;
+
+ WriteStr( o_rOut, i_sSeparator );
+
+ const char * sEnd = strchr( pHeapTop->Key(), ' ' );
+ if (sEnd != 0)
+ {
+ const char * sQuali = strrchr( pHeapTop->Key(), ' ' ) + 1;
+ WriteStr( o_rOut, sQuali );
+ WriteStr( o_rOut, "." );
+ o_rOut.write( pHeapTop->Key(), sEnd - pHeapTop->Key() );
+ }
+ else
+ WriteStr( o_rOut, pHeapTop->Key() );
+ } // end for
+
+ if (pLastHeapTop != 0)
+ {
+ delete pLastHeapTop;
+ pLastHeapTop = 0;
+ }
}