mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
remove dead code
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7861 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,341 +0,0 @@
|
||||
// $Id$
|
||||
// Copyright (C) 1997 ISOGEN International Corp. and TechnoTeacher, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// <Restrictions>
|
||||
// This file and its associated materials are copyrighted material of
|
||||
// ISOGEN International Corp. (ISOGEN) and TechnoTeacher,
|
||||
// Inc. (TechnoTeacher). License to copy and use this file and its
|
||||
// associated materials is granted to everyone, free of charge, with
|
||||
// the following restrictions: (1) The ISOGEN and TechnoTeacher
|
||||
// copyright statement must be maintained in any copies. (2) New
|
||||
// materials derived from these materials must indicate their source,
|
||||
// including references to the ISOGEN and TechnoTeacher web sites
|
||||
// (www.isogen.com and www.techno.com). (3) These materials may not be
|
||||
// sold in any form without the express written permission of ISOGEN
|
||||
// and TechnoTeacher. [However, feel free to sell things you create
|
||||
// from these materials as long as the things you create are truly
|
||||
// different in function--we want to encourage people to learn from
|
||||
// these materials and benefit from having learned--we just don't want
|
||||
// others to sell what we're giving away.]
|
||||
// </Restrictions>
|
||||
|
||||
#include "config.h"
|
||||
#include "DtdParser.h"
|
||||
|
||||
#include "macros.h"
|
||||
#include "sptchar.h"
|
||||
#include "CodingSystemKit.h"
|
||||
|
||||
#include "PosixStorage.h"
|
||||
#ifdef SP_WININET
|
||||
#include "WinInetStorage.h"
|
||||
#else
|
||||
#include "URLStorage.h"
|
||||
#endif
|
||||
#include "LiteralStorage.h"
|
||||
#include "NotationStorage.h"
|
||||
#include "ExtendEntityManager.h"
|
||||
#include "SOEntityCatalog.h"
|
||||
|
||||
#include "ErrorCountEventHandler.h"
|
||||
|
||||
#ifndef SP_DEFAULT_ENCODING
|
||||
#ifdef WIN32
|
||||
#define SP_DEFAULT_ENCODING SP_T("WINDOWS")
|
||||
#else
|
||||
#define SP_DEFAULT_ENCODING SP_T("IS8859-1")
|
||||
#endif
|
||||
#endif /* not SP_DEFAULT_ENCODING */
|
||||
|
||||
#ifndef SGML_SEARCH_PATH_DEFAULT
|
||||
#define SGML_SEARCH_PATH_DEFAULT SP_T("")
|
||||
#endif
|
||||
|
||||
#ifndef SGML_CATALOG_FILES_DEFAULT
|
||||
#define SGML_CATALOG_FILES_DEFAULT SP_T("")
|
||||
#endif /* not SGML_CATALOG_FILES_DEFAULT */
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
namespace SP_NAMESPACE {
|
||||
#endif
|
||||
|
||||
#ifdef SP_MSDOS_FILENAMES
|
||||
const Char FILE_SEP = ';';
|
||||
#else
|
||||
const Char FILE_SEP = ':';
|
||||
#endif
|
||||
|
||||
DtdParser::
|
||||
DtdParser( const char * requiredInternalCode)
|
||||
: internalCharsetIsDocCharset_( 1),
|
||||
codingSystem_( 0),
|
||||
mapCatalogDocument_(0),
|
||||
mgr_( &nullMgr_)
|
||||
{
|
||||
initCodingSystem( requiredInternalCode);
|
||||
}
|
||||
|
||||
void
|
||||
DtdParser::
|
||||
setMessenger( Messenger * mgr)
|
||||
{
|
||||
mgr_ = mgr ? mgr : &nullMgr_;
|
||||
}
|
||||
|
||||
class DtdParserEventHandler
|
||||
: public ErrorCountEventHandler
|
||||
{
|
||||
public:
|
||||
DtdParserEventHandler( Messenger *);
|
||||
void message( MessageEvent *);
|
||||
private:
|
||||
Messenger * mgr_;
|
||||
};
|
||||
|
||||
DtdParserEventHandler::
|
||||
DtdParserEventHandler( Messenger * mgr)
|
||||
: mgr_( mgr)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
DtdParserEventHandler::
|
||||
message( MessageEvent * event)
|
||||
{
|
||||
// ignore ParserMessages::documentEndProlog and ParserMessages::documentElementUndefined
|
||||
if ( event->message().type->number() != 45 && event->message().type->number() != 319) {
|
||||
mgr_->dispatchMessage( event->message());
|
||||
}
|
||||
ErrorCountEventHandler::message( event);
|
||||
}
|
||||
|
||||
ConstPtr< Dtd>
|
||||
DtdParser::
|
||||
parseDtd( const StringC & sysid)
|
||||
{
|
||||
DtdParserEventHandler handler( mgr_);
|
||||
|
||||
SgmlParser::Params sdParams;
|
||||
sdParams.sysid = convertInput( SP_T( "<LITERAL> "));
|
||||
sdParams.entityManager = entityManager().pointer();
|
||||
sdParams.options = &options_;
|
||||
sdParser_.init( sdParams);
|
||||
sdParser_.parseAll( handler, handler.cancelPtr());
|
||||
|
||||
SgmlParser::Params params;
|
||||
params.sysid = sysid;
|
||||
params.entityType = SgmlParser::Params::dtd;
|
||||
// unnecessary, since params.doctypeName starts out empty anyway.
|
||||
// params.doctypeName = convertInput( SP_T( ""));
|
||||
params.entityManager = entityManager().pointer();
|
||||
params.options = &options_;
|
||||
params.parent = &sdParser_;
|
||||
parser_.init( params);
|
||||
parser_.parseAll( handler, handler.cancelPtr());
|
||||
|
||||
Ptr< Dtd> dtd( parser_.baseDtd());
|
||||
delete dtd->removeElementType( params.doctypeName);
|
||||
|
||||
return dtd;
|
||||
}
|
||||
|
||||
Boolean
|
||||
stringMatches( const SP_TCHAR * s, const char * key)
|
||||
{
|
||||
for (; *key != '\0'; s++, key++) {
|
||||
if (*s != tolower(*key) && *s != toupper(*key))
|
||||
return 0;
|
||||
}
|
||||
return *s == '\0';
|
||||
}
|
||||
|
||||
void
|
||||
DtdParser::
|
||||
initCodingSystem( const char * requiredInternalCode)
|
||||
{
|
||||
const char *name = requiredInternalCode;
|
||||
#ifdef SP_MULTI_BYTE
|
||||
char buf[256];
|
||||
if (!name) {
|
||||
const SP_TCHAR *internalCode = tgetenv(SP_T("SP_SYSTEM_CHARSET"));
|
||||
if (internalCode) {
|
||||
buf[255] = '\0';
|
||||
for (size_t i = 0; i < 255; i++) {
|
||||
buf[i] = internalCode[i];
|
||||
if (buf[i] == '\0')
|
||||
break;
|
||||
}
|
||||
name = buf;
|
||||
}
|
||||
}
|
||||
if (requiredInternalCode)
|
||||
internalCharsetIsDocCharset_ = 0;
|
||||
else {
|
||||
const SP_TCHAR *useInternal = tgetenv(SP_T("SP_CHARSET_FIXED"));
|
||||
if (useInternal
|
||||
&& (stringMatches(useInternal, "YES")
|
||||
|| stringMatches(useInternal, "1")))
|
||||
internalCharsetIsDocCharset_ = 0;
|
||||
}
|
||||
#endif /* SP_MULTI_BYTE */
|
||||
codingSystemKit_ = CodingSystemKit::make(name);
|
||||
const SP_TCHAR *codingName = tgetenv(internalCharsetIsDocCharset_
|
||||
? SP_T("SP_BCTF")
|
||||
: SP_T("SP_ENCODING"));
|
||||
if (codingName)
|
||||
codingSystem_ = lookupCodingSystem(codingName);
|
||||
#ifdef SP_MULTI_BYTE
|
||||
if (!codingSystem_ && !internalCharsetIsDocCharset_)
|
||||
codingSystem_ = lookupCodingSystem(SP_DEFAULT_ENCODING);
|
||||
#endif
|
||||
if (!codingSystem_
|
||||
#ifndef SP_WIDE_SYSTEM
|
||||
|| codingSystem_->fixedBytesPerChar() > 1
|
||||
#endif
|
||||
)
|
||||
codingSystem_ = codingSystemKit_->identityCodingSystem();
|
||||
}
|
||||
|
||||
const CodingSystem *
|
||||
DtdParser::
|
||||
lookupCodingSystem( const AppChar * codingName)
|
||||
{
|
||||
#define MAX_CS_NAME 50
|
||||
if (tcslen(codingName) < MAX_CS_NAME) {
|
||||
char buf[MAX_CS_NAME];
|
||||
int i;
|
||||
for (i = 0; codingName[i] != SP_T('\0'); i++) {
|
||||
SP_TUCHAR c = codingName[i];
|
||||
#ifdef SP_WIDE_SYSTEM
|
||||
if (c > (unsigned char)-1)
|
||||
return 0;
|
||||
#endif
|
||||
buf[i] = char(c);
|
||||
}
|
||||
buf[i] = '\0';
|
||||
return codingSystemKit_->makeCodingSystem(buf, internalCharsetIsDocCharset_);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
StringC
|
||||
DtdParser::
|
||||
convertInput( const SP_TCHAR * s)
|
||||
{
|
||||
#ifdef SP_WIDE_SYSTEM
|
||||
StringC str(s, wcslen(s));
|
||||
#else
|
||||
StringC str(codingSystem()->convertIn(s));
|
||||
#endif
|
||||
for (size_t i = 0; i < str.size(); i++)
|
||||
if (str[i] == '\n')
|
||||
str[i] = '\r';
|
||||
return str;
|
||||
}
|
||||
|
||||
Boolean
|
||||
DtdParser::
|
||||
makeSystemId( int nFiles, AppChar * const * files, StringC & result)
|
||||
{
|
||||
Vector<StringC> filenames(nFiles == 0 ? 1 : nFiles);
|
||||
int i;
|
||||
for (i = 0; i < nFiles; i++)
|
||||
filenames[i] = convertInput(tcscmp(files[i], SP_T("-")) == 0
|
||||
? SP_T("<OSFD>0")
|
||||
: files[i]);
|
||||
if (nFiles == 0)
|
||||
filenames[0] = convertInput(SP_T("<OSFD>0"));
|
||||
return entityManager()->mergeSystemIds(filenames,
|
||||
mapCatalogDocument_,
|
||||
systemCharset(),
|
||||
*mgr_,
|
||||
result);
|
||||
}
|
||||
|
||||
Ptr< ExtendEntityManager> &
|
||||
DtdParser::
|
||||
entityManager()
|
||||
{
|
||||
if (!entityManager_.isNull())
|
||||
return entityManager_;
|
||||
PosixStorageManager *sm
|
||||
= new PosixStorageManager("OSFILE",
|
||||
&systemCharset(),
|
||||
#ifndef SP_WIDE_SYSTEM
|
||||
codingSystem(),
|
||||
#endif
|
||||
5);
|
||||
size_t i;
|
||||
for (i = 0; i < searchDirs_.size(); i++)
|
||||
sm->addSearchDir(convertInput(searchDirs_[i]));
|
||||
{
|
||||
const AppChar *e = tgetenv(SP_T("SGML_SEARCH_PATH"));
|
||||
if (!e)
|
||||
e = SGML_SEARCH_PATH_DEFAULT;
|
||||
if (*e) {
|
||||
StringC str(convertInput(e));
|
||||
size_t i = 0;
|
||||
size_t start = 0;
|
||||
for (;;) {
|
||||
if (i == str.size() || str[i] == FILE_SEP) {
|
||||
sm->addSearchDir(StringC(str.data() + start,
|
||||
i - start));
|
||||
if (i == str.size())
|
||||
break;
|
||||
start = ++i;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entityManager_ = ExtendEntityManager::make(sm,
|
||||
codingSystem(),
|
||||
inputCodingSystemKit(),
|
||||
internalCharsetIsDocCharset_);
|
||||
#ifdef SP_WININET
|
||||
entityManager_->registerStorageManager(new WinInetStorageManager("URL"));
|
||||
#else
|
||||
entityManager_->registerStorageManager(new URLStorageManager("URL"));
|
||||
#endif
|
||||
entityManager_->registerStorageManager(new LiteralStorageManager("LITERAL"));
|
||||
entityManager_->registerStorageManager(new NotationStorageManager("CLSID"));
|
||||
entityManager_->registerStorageManager(new NotationStorageManager("MIMETYPE"));
|
||||
Vector<StringC> v;
|
||||
for (i = 0; i < catalogSysids_.size(); i++)
|
||||
// filenames specified on command-line must exist
|
||||
v.push_back(convertInput(catalogSysids_[i]));
|
||||
{
|
||||
const AppChar *e = tgetenv(SP_T("SGML_CATALOG_FILES"));
|
||||
if (!e)
|
||||
e = SGML_CATALOG_FILES_DEFAULT;
|
||||
if (*e) {
|
||||
StringC str(convertInput(e));
|
||||
size_t i = 0;
|
||||
size_t start = 0;
|
||||
for (;;) {
|
||||
if (i == str.size() || str[i] == FILE_SEP) {
|
||||
v.push_back(StringC(str.data() + start,
|
||||
i - start));
|
||||
if (i == str.size())
|
||||
break;
|
||||
start = ++i;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
entityManager_->setCatalogManager(SOCatalogManager::make(v,
|
||||
catalogSysids_.size(),
|
||||
&systemCharset(),
|
||||
&systemCharset(),
|
||||
0));
|
||||
return entityManager_;
|
||||
}
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
@@ -1,120 +0,0 @@
|
||||
// $Id$
|
||||
// Copyright (C) 1997 ISOGEN International Corp. and TechnoTeacher, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// <Restrictions>
|
||||
// This file and its associated materials are copyrighted material of
|
||||
// ISOGEN International Corp. (ISOGEN) and TechnoTeacher,
|
||||
// Inc. (TechnoTeacher). License to copy and use this file and its
|
||||
// associated materials is granted to everyone, free of charge, with
|
||||
// the following restrictions: (1) The ISOGEN and TechnoTeacher
|
||||
// copyright statement must be maintained in any copies. (2) New
|
||||
// materials derived from these materials must indicate their source,
|
||||
// including references to the ISOGEN and TechnoTeacher web sites
|
||||
// (www.isogen.com and www.techno.com). (3) These materials may not be
|
||||
// sold in any form without the express written permission of ISOGEN
|
||||
// and TechnoTeacher. [However, feel free to sell things you create
|
||||
// from these materials as long as the things you create are truly
|
||||
// different in function--we want to encourage people to learn from
|
||||
// these materials and benefit from having learned--we just don't want
|
||||
// others to sell what we're giving away.]
|
||||
// </Restrictions>
|
||||
|
||||
#ifndef DtdParser_INCLUDED
|
||||
#define DtdParser_INCLUDED 1
|
||||
|
||||
#include "Dtd.h"
|
||||
#include "Ptr.h"
|
||||
#include "Vector.h"
|
||||
#include "CodingSystem.h"
|
||||
#include "CodingSystemKit.h"
|
||||
#include "SgmlParser.h"
|
||||
#include "ParserOptions.h"
|
||||
#include "ExtendEntityManager.h"
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
namespace SP_NAMESPACE {
|
||||
#endif
|
||||
|
||||
class DtdParser {
|
||||
public:
|
||||
DtdParser( const char * requiredInternalCode = 0);
|
||||
void setMessenger( Messenger *);
|
||||
|
||||
ConstPtr< Dtd> parseDtd( const StringC & sysid);
|
||||
|
||||
#ifdef SP_WIDE_SYSTEM
|
||||
typedef wchar_t AppChar;
|
||||
#else
|
||||
typedef char AppChar;
|
||||
#endif
|
||||
const CodingSystem * codingSystem();
|
||||
const CharsetInfo & systemCharset();
|
||||
ConstPtr< InputCodingSystemKit> inputCodingSystemKit();
|
||||
StringC convertInput( const AppChar * s);
|
||||
|
||||
Boolean makeSystemId( int nFiles, AppChar * const * files, StringC & result);
|
||||
Ptr< ExtendEntityManager> & entityManager();
|
||||
|
||||
SgmlParser & parser();
|
||||
|
||||
private:
|
||||
Messenger * mgr_;
|
||||
NullMessenger nullMgr_;
|
||||
|
||||
// Coding system stuff
|
||||
void initCodingSystem( const char * requiredInternalCode);
|
||||
const CodingSystem * lookupCodingSystem( const AppChar * codingName);
|
||||
Boolean internalCharsetIsDocCharset_;
|
||||
Ptr< CodingSystemKit> codingSystemKit_;
|
||||
const CodingSystem * codingSystem_;
|
||||
|
||||
// Entity manager stuff
|
||||
Vector< const AppChar *> searchDirs_;
|
||||
Vector< const AppChar *> catalogSysids_;
|
||||
Boolean mapCatalogDocument_;
|
||||
Ptr< ExtendEntityManager> entityManager_;
|
||||
|
||||
// SGML Parser stuff
|
||||
ParserOptions options_;
|
||||
SgmlParser sdParser_;
|
||||
SgmlParser parser_;
|
||||
};
|
||||
|
||||
inline
|
||||
const CodingSystem *
|
||||
DtdParser::
|
||||
codingSystem()
|
||||
{
|
||||
return codingSystem_;
|
||||
}
|
||||
|
||||
inline
|
||||
ConstPtr< InputCodingSystemKit>
|
||||
DtdParser::
|
||||
inputCodingSystemKit()
|
||||
{
|
||||
return codingSystemKit_.pointer();
|
||||
}
|
||||
|
||||
inline
|
||||
const CharsetInfo &
|
||||
DtdParser::
|
||||
systemCharset()
|
||||
{
|
||||
return codingSystemKit_->systemCharset();
|
||||
}
|
||||
|
||||
inline
|
||||
SgmlParser &
|
||||
DtdParser::
|
||||
parser()
|
||||
{
|
||||
return parser_;
|
||||
}
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not DtdParser_INCLUDED */
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
Note that some of the code in this directory is covered by
|
||||
ISOGEN and TechnoTeacher copyrights. On first reading, these
|
||||
copyrights appear to be restrictive. However, the parenthetical
|
||||
remarks in thier license seems to indicate that a larger, derived
|
||||
work is no longer subject to thier license. Since all of the rest
|
||||
of the stuff in this directory is a larger, derived work, it would
|
||||
appear that thier license doesn't apply, and that the whole can be
|
||||
safely GPL'ed.
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
EXTRA_DIST = \
|
||||
DtdParser.C \
|
||||
DtdParser.h \
|
||||
LICENSE \
|
||||
README \
|
||||
example.txt \
|
||||
parseDtd.C \
|
||||
parseOfx.C \
|
||||
pfxBaseTypes.C \
|
||||
pfxBaseTypes.h \
|
||||
pfxCompTypes.C \
|
||||
pfxCompTypes.h \
|
||||
pfxLangOut.C \
|
||||
pfxLangOut.h \
|
||||
pfxUtils.C \
|
||||
pfxUtils.h \
|
||||
simple.C
|
||||
@@ -1,53 +0,0 @@
|
||||
|
||||
This directory contains some experimental code to handle
|
||||
OFX (Open Financial Exchange) messages.
|
||||
|
||||
The most interesting thing here is the DTD parser "parseOfx"
|
||||
which attempts to build a C++ interface that models the
|
||||
structure of the OFX DTD's. It *almost* works. There
|
||||
are some exceptional cases that are not properly handled.
|
||||
|
||||
Next on the list of work items is to extend the parser so
|
||||
that it will also generate an implementation for the interface.
|
||||
Specifically, it should automatically create code for constructors,
|
||||
destructors, as well as SGML input & output routines (parsers,
|
||||
of a sort).
|
||||
|
||||
To check this out, run parseOfx like so:
|
||||
> parseOfx dtd/ofxmain.dtd
|
||||
|
||||
It will print the C++ decls to stdout.
|
||||
|
||||
--------------------------------------------------------------
|
||||
|
||||
HTTP tool:
|
||||
http://www.inf.ufrgs.br/~sagula/urlget.html
|
||||
|
||||
OFX financicial institution list:
|
||||
https://ofx-prod-filist.intuit.com/qw0700/filist.asp
|
||||
|
||||
SSLeay rpm's:
|
||||
http://www.sabotage.net/redhat/ssl.html
|
||||
http://ftp.tu-clausthal.de/pub/TEXT/EXPERT/linux/redhat-security/i386
|
||||
http://ftp.tu-clausthal.de/pub/TEXT/EXPERT/linux/redhat-security/SRPMS
|
||||
|
||||
--------------------------------------------------------------
|
||||
|
||||
To build stuff in this directory, you will needs James Clark's
|
||||
SGML Parser. This can be obtained at
|
||||
http://www.jclark.com/sp/index.htm
|
||||
Also:
|
||||
ftp.debian.org/pub/debian/dists/frozen/main/binary-i386/text/sp_1.3-1.1-4.deb
|
||||
|
||||
This directory contains code from
|
||||
ftp://ftp.techno.com/TechnoTeacher/parseDtd/parseDtd.zip
|
||||
|
||||
parseDtd.C: the sample parser from TechnoTeacher
|
||||
|
||||
parseOfx.C: the mangled parser I'm hacking on.
|
||||
|
||||
dtd/ofxmain.dtd: a hacked version of the original dtd, with
|
||||
the intent of exposing the base types.
|
||||
|
||||
--linas
|
||||
March 1998
|
||||
@@ -1,126 +0,0 @@
|
||||
From: ueli (urutishauser@bigfoot.com)
|
||||
|
||||
as example, a logon request. the result is something like that:
|
||||
|
||||
---------------
|
||||
<OFX>
|
||||
<SIGNONMSGSRQV1>
|
||||
<SONRQ>
|
||||
<DTCLIENT>19980411101000
|
||||
</DTCLIENT>
|
||||
<USERID>xxxxxx
|
||||
</USERID>
|
||||
<USERPASS>xxxxxx
|
||||
</USERPASS>
|
||||
<LANGUAGE>ENG
|
||||
</LANGUAGE>
|
||||
<APPID>GNUCash_OFX
|
||||
</APPID>
|
||||
<APPVER>0001
|
||||
</APPVER>
|
||||
</SONRQ>
|
||||
</SIGNONMSGSRQV1>
|
||||
[...something more like a investement statement download request...]
|
||||
</OFX>
|
||||
----------------------------------------------------------
|
||||
|
||||
class hierarchy
|
||||
|
||||
OFX
|
||||
---> SIGNONMSGSRQV1
|
||||
--> SONRQ
|
||||
-->DTCLIENT
|
||||
-->USERID
|
||||
-->USERPASS
|
||||
-->LANGUAGE
|
||||
-->APPID
|
||||
-->APPVER
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
(copy from junk.C)
|
||||
|
||||
class cfxSignonmsgsrsv1;
|
||||
class cfxSonrs;
|
||||
|
||||
class cfxSignonmsgsrsv1
|
||||
{
|
||||
public:
|
||||
cfxSignonmsgsrsv1 (void); // constructor
|
||||
virtual ~cfxSignonmsgsrsv1 (); // destructor
|
||||
|
||||
|
||||
// Sonrs *must* be present
|
||||
cfxSonrs *sonrs;
|
||||
nchtrnrs *pinchtrnrs;
|
||||
|
||||
// Challengetrnrs may be a null pointer
|
||||
cfxChallengetrnrs *challengetrnrs;
|
||||
};
|
||||
|
||||
|
||||
class cfxSonrs
|
||||
{
|
||||
public:
|
||||
cfxSonrs (void); // constructor
|
||||
virtual ~cfxSonrs (); // destructor
|
||||
|
||||
|
||||
// Status *must* be present
|
||||
cfxStatus *status;
|
||||
bfxDttm *dtserver;
|
||||
bfxStr *userkey;
|
||||
bfxDttm *tskeyexpire;
|
||||
bfxStr *language;
|
||||
bfxDttm *dtprofup;
|
||||
bfxDttm *dtacctup;
|
||||
|
||||
// Fi may be a null pointer
|
||||
cfxFi *fi;
|
||||
bfxStr *sesscookie;
|
||||
};
|
||||
|
||||
class cfxOfx
|
||||
{
|
||||
public:
|
||||
// Signonmsgsrsv1 *must* be present
|
||||
cfxSignonmsgsrsv1 *signonmsgsrsv1;
|
||||
|
||||
..
|
||||
}
|
||||
|
||||
----------------------------------------------------------
|
||||
some pseudo-code to produce a login request:
|
||||
|
||||
{
|
||||
ofxrequest = new cfxOfx();
|
||||
ofxreqeust->signonmsgsrsv1->sonrs->dtserver="199811111";
|
||||
|
||||
...
|
||||
|
||||
//all needed variables
|
||||
|
||||
|
||||
// ofx_request_type = login/investement statement
|
||||
// download/billings/creditcard
|
||||
if (ofxrequest->Valid(ofx_request_type))
|
||||
{
|
||||
ofxrequest->ExportRequest(ofx_request_type);
|
||||
|
||||
request = new HTTPRequest();
|
||||
repuest->CreateHeader();
|
||||
request->AddContent(ofxrequest->GetContent());
|
||||
if (request->SendRequest())
|
||||
{
|
||||
//now read in the result in a new ofxrequest structure
|
||||
ofxresponse = new cfxOfx();
|
||||
//or not cfxOfx, cfxOfx i eventually only for request
|
||||
|
||||
request->ParseResponse( ofxresponse );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,301 +0,0 @@
|
||||
// $Id$
|
||||
// Copyright (C) 1997 ISOGEN International Corp. and TechnoTeacher, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// <Restrictions>
|
||||
// This file and its associated materials are copyrighted material of
|
||||
// ISOGEN International Corp. (ISOGEN) and TechnoTeacher,
|
||||
// Inc. (TechnoTeacher). License to copy and use this file and its
|
||||
// associated materials is granted to everyone, free of charge, with
|
||||
// the following restrictions: (1) The ISOGEN and TechnoTeacher
|
||||
// copyright statement must be maintained in any copies. (2) New
|
||||
// materials derived from these materials must indicate their source,
|
||||
// including references to the ISOGEN and TechnoTeacher web sites
|
||||
// (www.isogen.com and www.techno.com). (3) These materials may not be
|
||||
// sold in any form without the express written permission of ISOGEN
|
||||
// and TechnoTeacher. [However, feel free to sell things you create
|
||||
// from these materials as long as the things you create are truly
|
||||
// different in function--we want to encourage people to learn from
|
||||
// these materials and benefit from having learned--we just don't want
|
||||
// others to sell what we're giving away.]
|
||||
// </Restrictions>
|
||||
|
||||
#include "config.h"
|
||||
#include "DtdParser.h"
|
||||
#include "OutputCharStream.h"
|
||||
|
||||
#define OUTPUT_MESSAGES
|
||||
|
||||
#ifdef OUTPUT_MESSAGES
|
||||
#include "sptchar.h"
|
||||
#include "MessageReporter.h"
|
||||
#include "MessageTable.h"
|
||||
#endif
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
namespace SP_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SP_MANUAL_INST
|
||||
|
||||
#define SP_DEFINE_TEMPLATES
|
||||
#include "Owner.h"
|
||||
#undef SP_DEFINE_TEMPLATES
|
||||
|
||||
#include "Message.h"
|
||||
|
||||
#ifdef SP_ANSI_CLASS_INST
|
||||
template class Owner< Messenger>;
|
||||
#else
|
||||
typedef Owner< Messenger> Dummy_0;
|
||||
#endif
|
||||
|
||||
#endif /* SP_MANUAL_INST */
|
||||
|
||||
|
||||
static FileOutputByteStream standardOutput(1, 0);
|
||||
static FileOutputByteStream standardError(2, 0);
|
||||
|
||||
#ifdef OUTPUT_MESSAGES
|
||||
|
||||
class MyMessageReporter
|
||||
: public MessageReporter
|
||||
{
|
||||
public:
|
||||
MyMessageReporter( const InputCodingSystem *, OutputCharStream *);
|
||||
private:
|
||||
Boolean getMessageText( const MessageFragment &, StringC &);
|
||||
const InputCodingSystem * codingSystem_;
|
||||
};
|
||||
|
||||
MyMessageReporter::
|
||||
MyMessageReporter( const InputCodingSystem * codesys,
|
||||
OutputCharStream * errorStream)
|
||||
: MessageReporter( errorStream),
|
||||
codingSystem_( codesys)
|
||||
{
|
||||
}
|
||||
|
||||
Boolean
|
||||
MyMessageReporter::
|
||||
getMessageText( const MessageFragment & frag, StringC & text)
|
||||
{
|
||||
String<SP_TCHAR> str;
|
||||
if (!MessageTable::instance()->getText(frag, str))
|
||||
return 0;
|
||||
#ifdef SP_WIDE_SYSTEM
|
||||
text.assign((const Char *)str.data(), str.size());
|
||||
#else
|
||||
str += 0;
|
||||
text = codingSystem_->convertIn(str.data());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* OUTPUT_MESSAGES */
|
||||
|
||||
void
|
||||
outputModelGroup( OutputCharStream & os, const ModelGroup * modelGroup, unsigned level)
|
||||
{
|
||||
os << "( ";
|
||||
level++;
|
||||
const char * connector = 0x0;
|
||||
switch ( modelGroup->connector()) {
|
||||
case ModelGroup::andConnector:
|
||||
connector = " &";
|
||||
break;
|
||||
case ModelGroup::orConnector:
|
||||
connector = " |";
|
||||
break;
|
||||
case ModelGroup::seqConnector:
|
||||
connector = ",";
|
||||
break;
|
||||
}
|
||||
unsigned i = 0;
|
||||
while ( i < modelGroup->nMembers()) {
|
||||
const ContentToken & token = modelGroup->member( i);
|
||||
const ModelGroup * subModel = token.asModelGroup();
|
||||
Boolean tokenIsPcdata = false;
|
||||
if ( subModel)
|
||||
outputModelGroup( os, subModel, level);
|
||||
else {
|
||||
const LeafContentToken * leaf = token.asLeafContentToken();
|
||||
const ElementType * elementType = leaf->elementType();
|
||||
if ( elementType)
|
||||
os << elementType->name();
|
||||
else {
|
||||
tokenIsPcdata = true;
|
||||
os << "#PCDATA";
|
||||
}
|
||||
}
|
||||
if ( !tokenIsPcdata) {
|
||||
switch ( token.occurrenceIndicator()) {
|
||||
case ContentToken::none:
|
||||
break;
|
||||
case ContentToken::opt:
|
||||
os << "?";
|
||||
break;
|
||||
case ContentToken::plus:
|
||||
os << "+";
|
||||
break;
|
||||
case ContentToken::rep:
|
||||
os << "*";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( ++i >= modelGroup->nMembers())
|
||||
break;
|
||||
os << connector << "\n";
|
||||
unsigned l = level;
|
||||
while ( l--)
|
||||
os << " ";
|
||||
continue;
|
||||
}
|
||||
os << " )";
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int
|
||||
main( int argc, char ** argv)
|
||||
{
|
||||
if ( argc < 2)
|
||||
return 1;
|
||||
|
||||
DtdParser parser;
|
||||
|
||||
#ifdef OUTPUT_MESSAGES
|
||||
Owner< Messenger> mgr;
|
||||
if ( argv[ 1][ 0] != '-' || argv[ 1][ 1] != 's' || argv[ 1][ 2] != '\0') {
|
||||
mgr = new MyMessageReporter( parser.codingSystem(),
|
||||
new EncodeOutputCharStream( &standardError,
|
||||
parser.codingSystem()));
|
||||
parser.setMessenger( mgr.pointer());
|
||||
}
|
||||
#endif
|
||||
|
||||
StringC sysid;
|
||||
parser.makeSystemId( argc - 1, argv + 1, sysid);
|
||||
ConstPtr< Dtd> dtd = parser.parseDtd( sysid);
|
||||
|
||||
if ( dtd.isNull())
|
||||
return 1;
|
||||
|
||||
EncodeOutputCharStream os( &standardOutput, parser.codingSystem());
|
||||
Dtd::ConstElementTypeIter e( dtd->elementTypeIter());
|
||||
const ElementType * type = e.next();
|
||||
while ( type) {
|
||||
os << type->name() << " =\n ";
|
||||
switch ( type->definition()->declaredContent()) {
|
||||
case ElementDefinition::modelGroup:
|
||||
outputModelGroup( os, type->definition()->compiledModelGroup()->modelGroup(), 1);
|
||||
break;
|
||||
case ElementDefinition::any: {
|
||||
Dtd::ConstElementTypeIter i( dtd->elementTypeIter());
|
||||
os << "( #PCDATA";
|
||||
const ElementType * type;
|
||||
while ( ( type = i.next()))
|
||||
os << " |\n " << type->name();
|
||||
os << " )*";
|
||||
break;
|
||||
}
|
||||
case ElementDefinition::cdata:
|
||||
os << "CDATA";
|
||||
break;
|
||||
case ElementDefinition::rcdata:
|
||||
os << "RCDATA";
|
||||
break;
|
||||
case ElementDefinition::empty:
|
||||
os << "EMPTY";
|
||||
break;
|
||||
}
|
||||
os << "\n";
|
||||
const AttributeDefinitionList * attlist = type->attributeDefTemp();
|
||||
if ( attlist) {
|
||||
os << "[\n";
|
||||
for ( size_t a = 0; a < attlist->size(); a++) {
|
||||
const AttributeDefinition * def = attlist->def( a);
|
||||
os << " " << def->name() << " : ";
|
||||
size_t indent = def->name().size() + 5;
|
||||
AttributeDefinitionDesc desc;
|
||||
def->getDesc( desc);
|
||||
switch ( desc.declaredValue) {
|
||||
case AttributeDefinitionDesc::cdata:
|
||||
os << "CDATA";
|
||||
break;
|
||||
case AttributeDefinitionDesc::name:
|
||||
os << "NAME";
|
||||
break;
|
||||
case AttributeDefinitionDesc::number:
|
||||
os << "NUMBER";
|
||||
break;
|
||||
case AttributeDefinitionDesc::nmtoken:
|
||||
os << "NMTOKEN";
|
||||
break;
|
||||
case AttributeDefinitionDesc::nutoken:
|
||||
os << "NUTOKEN";
|
||||
break;
|
||||
case AttributeDefinitionDesc::entity:
|
||||
os << "ENTITY";
|
||||
break;
|
||||
case AttributeDefinitionDesc::idref:
|
||||
os << "IDREF";
|
||||
break;
|
||||
case AttributeDefinitionDesc::names:
|
||||
os << "NAMES";
|
||||
break;
|
||||
case AttributeDefinitionDesc::numbers:
|
||||
os << "NUMBERS";
|
||||
break;
|
||||
case AttributeDefinitionDesc::nmtokens:
|
||||
os << "NMTOKENS";
|
||||
break;
|
||||
case AttributeDefinitionDesc::nutokens:
|
||||
os << "NUTOKENS";
|
||||
break;
|
||||
case AttributeDefinitionDesc::entities:
|
||||
os << "ENTITIES";
|
||||
break;
|
||||
case AttributeDefinitionDesc::idrefs:
|
||||
os << "IDREFS";
|
||||
break;
|
||||
case AttributeDefinitionDesc::id:
|
||||
os << "ID";
|
||||
break;
|
||||
case AttributeDefinitionDesc::notation:
|
||||
os << "NOTATION";
|
||||
indent += 8;
|
||||
case AttributeDefinitionDesc::nameTokenGroup: {
|
||||
os << "( ";
|
||||
indent += 2;
|
||||
size_t i;
|
||||
size_t v = 0;
|
||||
while ( v < desc.allowedValues.size()) {
|
||||
os << desc.allowedValues[ v];
|
||||
if ( ++v >= desc.allowedValues.size())
|
||||
break;
|
||||
os << " |\n";
|
||||
i = indent;
|
||||
while ( i--)
|
||||
os << " ";
|
||||
continue;
|
||||
}
|
||||
os << " )";
|
||||
break;
|
||||
}
|
||||
}
|
||||
os << "\n";
|
||||
}
|
||||
os << "]\n";
|
||||
}
|
||||
if ( !( type = e.next()))
|
||||
break;
|
||||
os << "\n";
|
||||
continue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
@@ -1,245 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// parseOfx.C
|
||||
//
|
||||
// FUNCTION:
|
||||
// Parses OFX dtd's
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas March 1998
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "DtdParser.h"
|
||||
#include "OutputCharStream.h"
|
||||
|
||||
#include "pfxBaseTypes.h"
|
||||
#include "pfxCompTypes.h"
|
||||
#include "pfxLangOut.h"
|
||||
#include "pfxUtils.h"
|
||||
|
||||
|
||||
// output messages is used to set up the SP parser
|
||||
// to dump it's error messages to stderr
|
||||
#define OUTPUT_MESSAGES
|
||||
|
||||
#ifdef OUTPUT_MESSAGES
|
||||
#include "sptchar.h"
|
||||
#include "MessageReporter.h"
|
||||
#include "MessageTable.h"
|
||||
#endif /* OUTPUT_MESSAGES */
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
namespace SP_NAMESPACE {
|
||||
#endif
|
||||
|
||||
#ifdef OUTPUT_MESSAGES
|
||||
#ifdef SP_MANUAL_INST
|
||||
|
||||
#define SP_DEFINE_TEMPLATES
|
||||
#include "Owner.h"
|
||||
#undef SP_DEFINE_TEMPLATES
|
||||
|
||||
#include "Message.h"
|
||||
|
||||
#ifdef SP_ANSI_CLASS_INST
|
||||
template class Owner< Messenger>;
|
||||
#else
|
||||
typedef Owner< Messenger> Dummy_0;
|
||||
#endif
|
||||
|
||||
#endif /* SP_MANUAL_INST */
|
||||
#endif /* OUTPUT_MESSAGES */
|
||||
|
||||
|
||||
static FileOutputByteStream standardOutput(1, 0);
|
||||
static FileOutputByteStream standardError(2, 0);
|
||||
|
||||
#ifdef OUTPUT_MESSAGES
|
||||
|
||||
class MyMessageReporter
|
||||
: public MessageReporter
|
||||
{
|
||||
public:
|
||||
MyMessageReporter( const InputCodingSystem *, OutputCharStream *);
|
||||
private:
|
||||
Boolean getMessageText( const MessageFragment &, StringC &);
|
||||
const InputCodingSystem * codingSystem_;
|
||||
};
|
||||
|
||||
MyMessageReporter::
|
||||
MyMessageReporter( const InputCodingSystem * codesys,
|
||||
OutputCharStream * errorStream)
|
||||
: MessageReporter( errorStream),
|
||||
codingSystem_( codesys)
|
||||
{
|
||||
}
|
||||
|
||||
Boolean
|
||||
MyMessageReporter::
|
||||
getMessageText( const MessageFragment & frag, StringC & text)
|
||||
{
|
||||
String<SP_TCHAR> str;
|
||||
if (!MessageTable::instance()->getText(frag, str))
|
||||
return 0;
|
||||
#ifdef SP_WIDE_SYSTEM
|
||||
text.assign((const Char *)str.data(), str.size());
|
||||
#else
|
||||
str += 0;
|
||||
text = codingSystem_->convertIn(str.data());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* OUTPUT_MESSAGES */
|
||||
|
||||
// ===========================================================
|
||||
|
||||
extern "C"
|
||||
|
||||
void Usage (char *progname)
|
||||
{
|
||||
printf ("Usage: %s <dtdfile> \n", progname);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int
|
||||
main( int argc, char ** argv)
|
||||
{
|
||||
if ( argc < 2) Usage (argv[0]);
|
||||
|
||||
DtdParser parser;
|
||||
|
||||
pfxCompoundType compoundTypeHandler;
|
||||
|
||||
#ifdef OUTPUT_MESSAGES
|
||||
Owner< Messenger> mgr;
|
||||
if ( argv[ 1][ 0] != '-' || argv[ 1][ 1] != 's' || argv[ 1][ 2] != '\0') {
|
||||
mgr = new MyMessageReporter( parser.codingSystem(),
|
||||
new EncodeOutputCharStream( &standardError,
|
||||
parser.codingSystem()));
|
||||
parser.setMessenger( mgr.pointer());
|
||||
}
|
||||
#endif
|
||||
|
||||
StringC sysid;
|
||||
parser.makeSystemId( argc - 1, argv + 1, sysid);
|
||||
ConstPtr< Dtd> dtd = parser.parseDtd( sysid);
|
||||
|
||||
if ( dtd.isNull()) {
|
||||
printf ("Error: specified dtd %s was null \n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
|
||||
compoundTypeHandler.prtout = new pfxOutDecl;
|
||||
|
||||
// ----------------------------------------------------
|
||||
// print everything
|
||||
time_t now = time (0);
|
||||
char * cnow = ctime (&now);
|
||||
|
||||
printf ("//\n");
|
||||
printf ("// This file automatically generated by %s \n", argv[0]);
|
||||
printf ("// Do not edit -- your changes will be lost! \n");
|
||||
printf ("// Generated on %s \n", cnow);
|
||||
printf ("//\n");
|
||||
printf ("//\n");
|
||||
compoundTypeHandler.PrintBaseTypes (0);
|
||||
|
||||
|
||||
printf ("//----------------------------------------------\n");
|
||||
printf ("//\n");
|
||||
printf ("// Forward declarations of classes\n");
|
||||
printf ("//\n");
|
||||
printf ("//\n");
|
||||
const ElementType * type;
|
||||
Dtd::ConstElementTypeIter e( dtd->elementTypeIter());
|
||||
type = e.next();
|
||||
while ( type) {
|
||||
|
||||
// see if is a base type
|
||||
char * varname = compoundTypeHandler.AddBaseVar (type);
|
||||
|
||||
if (!varname) {
|
||||
compoundTypeHandler.AddCompoundType (type);
|
||||
|
||||
switch ( type->definition()->declaredContent()) {
|
||||
case ElementDefinition::modelGroup:
|
||||
break;
|
||||
case ElementDefinition::any:
|
||||
break;
|
||||
default: {
|
||||
char * vname = pfxCharify (type->name());
|
||||
printf ("unexpected duuuuuuuuuuuuuuuuuuude: %s \n", vname);
|
||||
delete vname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const AttributeDefinitionList * attlist = type->attributeDefTemp();
|
||||
if ( attlist) {
|
||||
printf (" attribute lists duuuuuuuuuuuuuuuuuuuuuuuuuude \n");
|
||||
}
|
||||
|
||||
if ( !( type = e.next()))
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// print classes
|
||||
printf ("//----------------------------------------------\n");
|
||||
printf ("//\n");
|
||||
printf ("// Class declarations\n");
|
||||
printf ("//\n");
|
||||
printf ("//\n");
|
||||
|
||||
Dtd::ConstElementTypeIter ee( dtd->elementTypeIter());
|
||||
type = ee.next();
|
||||
while ( type) {
|
||||
|
||||
// see if is a base type
|
||||
char * varname = compoundTypeHandler.AddBaseVar (type);
|
||||
|
||||
if (!varname) {
|
||||
compoundTypeHandler.PrintClass (type);
|
||||
}
|
||||
|
||||
type = ee.next();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// print constructors
|
||||
printf ("//----------------------------------------------\n");
|
||||
printf ("//\n");
|
||||
printf ("// Constructors\n");
|
||||
printf ("//\n");
|
||||
printf ("//\n");
|
||||
|
||||
compoundTypeHandler.prtout = new pfxOutConstructor;
|
||||
|
||||
Dtd::ConstElementTypeIter eee( dtd->elementTypeIter());
|
||||
type = eee.next();
|
||||
while ( type) {
|
||||
|
||||
// see if is a base type
|
||||
char * varname = compoundTypeHandler.AddBaseVar (type);
|
||||
|
||||
if (!varname) {
|
||||
compoundTypeHandler.PrintClass (type);
|
||||
}
|
||||
|
||||
type = eee.next();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
@@ -1,238 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// basTypes.C
|
||||
//
|
||||
// FUNCTION:
|
||||
// Handles OFX base types
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas March 1998
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "DtdParser.h"
|
||||
|
||||
#include "pfxUtils.h"
|
||||
#include "pfxBaseTypes.h"
|
||||
|
||||
// ===========================================================
|
||||
// class pfxBaseType stores & handles base types
|
||||
|
||||
|
||||
pfxBaseType :: pfxBaseType (void)
|
||||
{
|
||||
prtout = 0x0;
|
||||
nvars = 0;
|
||||
varname[0] = 0x0;
|
||||
vartype[0] = 0x0;
|
||||
}
|
||||
|
||||
char *
|
||||
pfxBaseType :: AddBaseVar (const ElementType *type)
|
||||
{
|
||||
|
||||
// its not a base type unless we have a model group.
|
||||
if (ElementDefinition::modelGroup !=
|
||||
type->definition()->declaredContent()) return 0x0;
|
||||
|
||||
const ModelGroup * mg;
|
||||
mg = type->definition()->compiledModelGroup()->modelGroup();
|
||||
|
||||
// to be a base type, it must have exactly one member
|
||||
if (1 != mg->nMembers()) return 0x0;
|
||||
|
||||
const ContentToken & token = mg->member (0);
|
||||
|
||||
// anything with a sub-model cannot be a base type
|
||||
const ModelGroup * subModel = token.asModelGroup();
|
||||
if (subModel) return 0x0;
|
||||
|
||||
const LeafContentToken * leaf = token.asLeafContentToken();
|
||||
const ElementType * elementType = leaf->elementType();
|
||||
|
||||
if (!elementType) {
|
||||
char * name = pfxCharify (type->name());
|
||||
|
||||
printf ("Unkonwon, unexpected PCDATA: %s \n", name);
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
// now look to see if we have already processed this one
|
||||
char *vname = pfxCharify (type->name());
|
||||
|
||||
// if its already in out database, just return
|
||||
for (int i = 0; i<nvars; i++) {
|
||||
if (!strcmp (vname, varname[i])) {
|
||||
delete vname;
|
||||
return varname[i];
|
||||
}
|
||||
}
|
||||
|
||||
// look to see if this is a typ[e that we recognize
|
||||
char * vtype = pfxCharify (elementType->name());
|
||||
if (strcmp ("XACC-AMOUNT", vtype) &&
|
||||
strcmp ("XACC-BOOL", vtype) &&
|
||||
strcmp ("XACC-DTTM", vtype) &&
|
||||
strcmp ("XACC-ID", vtype) &&
|
||||
strcmp ("XACC-INT", vtype) &&
|
||||
strcmp ("XACC-PRICE", vtype) &&
|
||||
strcmp ("XACC-RATE", vtype) &&
|
||||
strcmp ("XACC-SRVRID", vtype) &&
|
||||
strcmp ("XACC-STR", vtype) &&
|
||||
strcmp ("XACC-URL", vtype) &&
|
||||
strcmp ("XACC-UUID", vtype)) {
|
||||
|
||||
delete vtype;
|
||||
delete vname;
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
// we haven't encounterd this before. Add it to our list.
|
||||
varname[nvars] = vname;
|
||||
vartype[nvars] = vtype;
|
||||
nvars ++;
|
||||
|
||||
return vname;
|
||||
}
|
||||
|
||||
void
|
||||
pfxBaseType :: PrintBaseTypes (int dent)
|
||||
{
|
||||
|
||||
DENT (dent); printf ("// Basic Types \n");
|
||||
DENT (dent); printf ("typedef double bfxAmount; \n");
|
||||
DENT (dent); printf ("typedef int bfxBool; \n");
|
||||
DENT (dent); printf ("typedef long int bfxDttm; \n");
|
||||
DENT (dent); printf ("typedef char * bfxId; \n");
|
||||
DENT (dent); printf ("typedef int bfxInt; \n");
|
||||
DENT (dent); printf ("typedef double bfxPrice; \n");
|
||||
DENT (dent); printf ("typedef double bfxRate; \n");
|
||||
DENT (dent); printf ("typedef char * bfxStr; \n");
|
||||
DENT (dent); printf ("typedef char * bfxSrvrid; \n");
|
||||
DENT (dent); printf ("typedef char * bfxUrl; \n");
|
||||
DENT (dent); printf ("typedef char bfxUuid [36]; \n");
|
||||
printf ("\n\n");
|
||||
}
|
||||
|
||||
void
|
||||
pfxBaseType :: PrintBaseDecl (const ContentToken & token)
|
||||
{
|
||||
// print an individual member
|
||||
const LeafContentToken * leaf = token.asLeafContentToken();
|
||||
const ElementType * elementType = leaf->elementType();
|
||||
if (!elementType) return;
|
||||
|
||||
char * varname = pfxCharify (elementType->name());
|
||||
|
||||
if (!varname) return;
|
||||
|
||||
char * vtype = GetBaseType (varname);
|
||||
if (!vtype) return;
|
||||
|
||||
char * decl;
|
||||
|
||||
if (!strcmp ("XACC-AMOUNT", vtype)) {
|
||||
decl = "bfxAmount";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-BOOL", vtype)) {
|
||||
decl = "bfxBool";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-DTTM", vtype)) {
|
||||
decl = "bfxDttm";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-ID", vtype)) {
|
||||
decl = "bfxId";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-INT", vtype)) {
|
||||
decl = "bfxInt";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-PRICE", vtype)) {
|
||||
decl = "bfxPrice";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-RATE", vtype)) {
|
||||
decl = "bfxRate";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-STR", vtype)) {
|
||||
decl = "bfxStr";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-SRVRID", vtype)) {
|
||||
decl = "bfxSrvrid";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-URL", vtype)) {
|
||||
decl = "bfxUrl";
|
||||
} else
|
||||
|
||||
if (!strcmp ("XACC-UUID", vtype)) {
|
||||
decl = "bfxUuid";
|
||||
} else
|
||||
|
||||
printf ("---> unknown type >%s<\n", vtype);
|
||||
|
||||
|
||||
// handle repeated lists
|
||||
pfxLangOutput::occ currance;
|
||||
switch ( token.occurrenceIndicator()) {
|
||||
|
||||
// element *must* occur
|
||||
case ContentToken::none:
|
||||
currance = pfxLangOutput::MUST;
|
||||
break;
|
||||
|
||||
// element may or may not occur
|
||||
case ContentToken::opt:
|
||||
currance = pfxLangOutput::OPT;
|
||||
break;
|
||||
|
||||
// element must occur at least once, maybe more times.
|
||||
case ContentToken::plus:
|
||||
currance = pfxLangOutput::PLUS;
|
||||
break;
|
||||
|
||||
// element may occur zero or more times
|
||||
case ContentToken::rep:
|
||||
currance = pfxLangOutput::REP;
|
||||
break;
|
||||
}
|
||||
|
||||
// printed var names will be lower case
|
||||
char * vname = pfxToLower (varname);
|
||||
|
||||
char * saveprefix = prtout->prefix;
|
||||
|
||||
prtout -> prefix = "";
|
||||
prtout -> PrintMember (currance, decl, vname);
|
||||
prtout -> prefix = saveprefix;
|
||||
|
||||
delete vname;
|
||||
delete varname;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
pfxBaseType :: GetBaseType (char * vname)
|
||||
{
|
||||
|
||||
for (int i = 0; i<nvars; i++) {
|
||||
if (!strcmp (vname, varname[i])) return vartype[i];
|
||||
}
|
||||
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
@@ -1,51 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// pfxBaseTypes.h
|
||||
//
|
||||
// FUNCTION:
|
||||
// Handles OFX base types
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas March 1998
|
||||
|
||||
#ifndef PFX_BASE_TYPES_H
|
||||
#define PFX_BASE_TYPES_H
|
||||
|
||||
#include "config.h"
|
||||
#include "DtdParser.h"
|
||||
|
||||
#include "pfxUtils.h"
|
||||
#include "pfxBaseTypes.h"
|
||||
#include "pfxLangOut.h"
|
||||
|
||||
// ===========================================================
|
||||
// class pfxBaseType stores & handles base types
|
||||
|
||||
// AddBaseVar adds a new variable with a base type.
|
||||
// returns pointer to variable name if a base type, else returns null.
|
||||
|
||||
#define MAXVARS 3000
|
||||
|
||||
class pfxBaseType {
|
||||
public:
|
||||
pfxBaseType (void);
|
||||
|
||||
char * AddBaseVar (const ElementType *);
|
||||
char * GetBaseType (char *varname);
|
||||
void PrintBaseTypes (int dent);
|
||||
void PrintBaseDecl (const ContentToken & token);
|
||||
|
||||
pfxLangOutput *prtout;
|
||||
|
||||
private:
|
||||
char * varname[MAXVARS];
|
||||
char * vartype[MAXVARS];
|
||||
int nvars;
|
||||
|
||||
};
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PFX_BASE_TYPES_H */
|
||||
@@ -1,438 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// pfxCompTypes.C
|
||||
//
|
||||
// FUNCTION:
|
||||
// Parses OFX dtd's
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas March 1998
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "DtdParser.h"
|
||||
|
||||
#include "pfxBaseTypes.h"
|
||||
#include "pfxCompTypes.h"
|
||||
#include "pfxUtils.h"
|
||||
|
||||
|
||||
// =====================================================
|
||||
|
||||
pfxCompoundType :: pfxCompoundType (void)
|
||||
{
|
||||
nclasses = 0;
|
||||
classname[0] = 0x0;
|
||||
}
|
||||
|
||||
char *
|
||||
pfxCompoundType :: IsClass (char * vname)
|
||||
{
|
||||
for (int i = 0; i<nclasses; i++) {
|
||||
if (!strcmp (vname, classname[i])) return classname[i];
|
||||
}
|
||||
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
char *
|
||||
pfxCompoundType :: AddCompoundType (const ElementType *type)
|
||||
{
|
||||
|
||||
// its not a compound type unless we have a model group.
|
||||
if (ElementDefinition::modelGroup !=
|
||||
type->definition()->declaredContent()) return 0x0;
|
||||
|
||||
// make sure its not a base type
|
||||
char * basename = AddBaseVar (type);
|
||||
if (basename) return 0x0;
|
||||
|
||||
const ModelGroup * mg;
|
||||
mg = type->definition()->compiledModelGroup()->modelGroup();
|
||||
|
||||
char * cname = pfxCharify (type->name());
|
||||
|
||||
classname [nclasses] = cname;
|
||||
nclasses ++;
|
||||
|
||||
char * pname = pfxCapLower (cname);
|
||||
printf ("class cfx%s;\n", pname);
|
||||
delete pname;
|
||||
|
||||
return cname;
|
||||
}
|
||||
|
||||
void
|
||||
pfxCompoundType :: PrintMember (const ContentToken & token)
|
||||
{
|
||||
if (!prtout) return;
|
||||
|
||||
// print an individual member
|
||||
const LeafContentToken * leaf = token.asLeafContentToken();
|
||||
const ElementType * elementType = leaf->elementType();
|
||||
if (!elementType) return;
|
||||
|
||||
char * varname = pfxCharify (elementType->name());
|
||||
|
||||
// see if its a base type -- e.g. int, double, etc.
|
||||
char * basetype = GetBaseType (varname);
|
||||
if (basetype) {
|
||||
PrintBaseDecl (token);
|
||||
} else {
|
||||
|
||||
// Not base type. Must be a class
|
||||
char * classtype = IsClass (varname);
|
||||
if (classtype) {
|
||||
char * decl = pfxCapLower (varname);
|
||||
char * var = pfxToLower (varname);
|
||||
|
||||
// look to see if the element occurs
|
||||
// once, more than once, etc.
|
||||
switch ( token.occurrenceIndicator()) {
|
||||
|
||||
// element *must* occur
|
||||
case ContentToken::none:
|
||||
prtout -> PrintMember (pfxLangOutput::MUST, decl, var);
|
||||
break;
|
||||
|
||||
// element may or may not occur
|
||||
case ContentToken::opt:
|
||||
prtout -> PrintMember (pfxLangOutput::OPT, decl, var);
|
||||
break;
|
||||
|
||||
// element must occur at least once, maybe more times.
|
||||
case ContentToken::plus:
|
||||
prtout -> PrintMember (pfxLangOutput::PLUS, decl, var);
|
||||
break;
|
||||
|
||||
// element may occur zero or more times
|
||||
case ContentToken::rep:
|
||||
prtout -> PrintMember (pfxLangOutput::REP, decl, var);
|
||||
break;
|
||||
}
|
||||
|
||||
delete decl;
|
||||
delete var;
|
||||
} else {
|
||||
printf (" this variable has no type -----> %s \n", varname);
|
||||
}
|
||||
}
|
||||
delete varname;
|
||||
}
|
||||
|
||||
int
|
||||
pfxCompoundType :: IsUnion (const ModelGroup * mg)
|
||||
{
|
||||
if (ModelGroup::orConnector == mg->connector()) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
pfxCompoundType :: GetUnnamedClassName (const ContentToken & untoken)
|
||||
{
|
||||
const ModelGroup * mg = untoken.asModelGroup();
|
||||
|
||||
if (!mg) {
|
||||
printf ("Error: GetUnnamedClassName: unexpected non model \n");
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
// The connector *must* be a sequence or a logical-AND type in order
|
||||
// for this to be a struct.
|
||||
if ((ModelGroup::andConnector != mg->connector()) &&
|
||||
(ModelGroup::seqConnector != mg->connector())) return 0x0;
|
||||
|
||||
|
||||
// create a long compound name
|
||||
// first, count the length of that name
|
||||
int i = 0;
|
||||
int namelen = 0;
|
||||
while (i < mg->nMembers()) {
|
||||
const ContentToken & token = mg->member( i);
|
||||
const ModelGroup * subModel = token.asModelGroup();
|
||||
|
||||
if (!subModel) {
|
||||
const LeafContentToken * leaf = token.asLeafContentToken();
|
||||
const ElementType * elementType = leaf->elementType();
|
||||
namelen += (elementType->name()).size() + 1;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// now, build the compund name
|
||||
i = 0;
|
||||
char * name = new char [namelen+1];
|
||||
name[0] = 0x0;
|
||||
while (i < mg->nMembers()) {
|
||||
const ContentToken & token = mg->member( i);
|
||||
const ModelGroup * subModel = token.asModelGroup();
|
||||
|
||||
if (!subModel) {
|
||||
const LeafContentToken * leaf = token.asLeafContentToken();
|
||||
const ElementType * elementType = leaf->elementType();
|
||||
|
||||
char * varname = pfxCharify (elementType->name());
|
||||
char * capname = pfxCapLower (varname);
|
||||
strcat (name, "_");
|
||||
strcat (name, capname);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
void
|
||||
pfxCompoundType :: PrintMacroDecl (const ContentToken & untoken)
|
||||
{
|
||||
const ModelGroup * mg = untoken.asModelGroup();
|
||||
|
||||
if (!mg) {
|
||||
printf ("Error: PrintMacroDecl: unexpected non model \n");
|
||||
return;
|
||||
}
|
||||
|
||||
// If connector is a sequence or a logical-AND type,
|
||||
// then treat as a class.
|
||||
if ((ModelGroup::andConnector == mg->connector()) ||
|
||||
(ModelGroup::seqConnector == mg->connector())) {
|
||||
|
||||
PrintUnnamedClassDecl (untoken);
|
||||
PrintUnnamedInstance (untoken);
|
||||
} else
|
||||
|
||||
// If the connector is a logical-OR connector,
|
||||
// then treat as a union
|
||||
if (ModelGroup::orConnector == mg->connector()) {
|
||||
PrintUnionDecl (untoken);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pfxCompoundType :: PrintUnnamedClassDecl (const ContentToken & untoken)
|
||||
{
|
||||
const ModelGroup * mg = untoken.asModelGroup();
|
||||
|
||||
if (!mg) {
|
||||
printf ("Error: PrintUnnamedClassDecl: unexpected non model \n");
|
||||
return;
|
||||
}
|
||||
|
||||
// The connector *must* be a sequence or a logical-AND type in order
|
||||
// for this to be a struct.
|
||||
if ((ModelGroup::andConnector != mg->connector()) &&
|
||||
(ModelGroup::seqConnector != mg->connector())) return;
|
||||
|
||||
char * name = GetUnnamedClassName (untoken);
|
||||
|
||||
// If the returned name of the thing is null, then
|
||||
// I think we can safely assume that this thing is
|
||||
// the result of a macro expansion in the DTD.
|
||||
// This means that there is no true heirarchy, even
|
||||
// though there is an appearent heirarchy. So,
|
||||
// don't let things nest. Just flatten it.
|
||||
// We flatten by not printing the prolog or epilogue
|
||||
// (since there really isn't a prolog or epilog).
|
||||
|
||||
// now, print the class definition
|
||||
if (name[0]) prtout->PrintClassProlog (name);
|
||||
int i = 0;
|
||||
while (i < mg->nMembers()) {
|
||||
const ContentToken & token = mg->member( i);
|
||||
const ModelGroup * subModel = token.asModelGroup();
|
||||
if (subModel) {
|
||||
printf (" // -------> begin flattening \n");
|
||||
PrintMacroDecl (token);
|
||||
printf (" // -------> end flattening \n");
|
||||
} else {
|
||||
// put the member elements into the class declaration
|
||||
PrintMember(token);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (name[0]) prtout->PrintClassEpilog (name);
|
||||
}
|
||||
|
||||
void
|
||||
pfxCompoundType :: PrintUnnamedInstance (const ContentToken & untoken)
|
||||
{
|
||||
const ModelGroup * mg = untoken.asModelGroup();
|
||||
|
||||
if (!mg) {
|
||||
printf ("Error: PrintUnnamedInstance: unexpected non model \n");
|
||||
return;
|
||||
}
|
||||
|
||||
// The connector *must* be a sequence or a logical-AND type in order
|
||||
// for this to be a struct.
|
||||
if ((ModelGroup::andConnector != mg->connector()) &&
|
||||
(ModelGroup::seqConnector != mg->connector())) return;
|
||||
|
||||
|
||||
char * name = GetUnnamedClassName (untoken);
|
||||
|
||||
// now handle repeated lists
|
||||
pfxLangOutput::occ currance;
|
||||
switch ( untoken.occurrenceIndicator()) {
|
||||
|
||||
// element *must* occur
|
||||
case ContentToken::none:
|
||||
currance = pfxLangOutput::MUST;
|
||||
break;
|
||||
|
||||
// element may or may not occur
|
||||
case ContentToken::opt:
|
||||
currance = pfxLangOutput::OPT;
|
||||
break;
|
||||
|
||||
// element must occur at least once, maybe more times.
|
||||
case ContentToken::plus:
|
||||
currance = pfxLangOutput::PLUS;
|
||||
break;
|
||||
|
||||
// element may occur zero or more times
|
||||
case ContentToken::rep:
|
||||
currance = pfxLangOutput::REP;
|
||||
break;
|
||||
}
|
||||
|
||||
prtout ->PrintMember (currance, name, name);
|
||||
}
|
||||
|
||||
void
|
||||
pfxCompoundType :: PrintUnionDecl (const ContentToken & untoken)
|
||||
{
|
||||
|
||||
const ModelGroup * mg = untoken.asModelGroup();
|
||||
|
||||
if (!mg) {
|
||||
printf ("Error: PrintUnionDecl: unexpected non model \n");
|
||||
return;
|
||||
}
|
||||
|
||||
// The connector *must* be logical-OR type in order
|
||||
// for this to be a union.
|
||||
if (ModelGroup::orConnector != mg->connector()) return;
|
||||
|
||||
// now handle repeated lists
|
||||
pfxLangOutput::occ currance;
|
||||
switch ( untoken.occurrenceIndicator()) {
|
||||
|
||||
// element *must* occur
|
||||
case ContentToken::none:
|
||||
currance = pfxLangOutput::MUST;
|
||||
break;
|
||||
|
||||
// element may or may not occur
|
||||
case ContentToken::opt:
|
||||
currance = pfxLangOutput::OPT;
|
||||
break;
|
||||
|
||||
// element must occur at least once, maybe more times.
|
||||
case ContentToken::plus:
|
||||
currance = pfxLangOutput::PLUS;
|
||||
break;
|
||||
|
||||
// element may occur zero or more times
|
||||
case ContentToken::rep:
|
||||
currance = pfxLangOutput::REP;
|
||||
break;
|
||||
}
|
||||
|
||||
// if there are any groups that occur,
|
||||
// lets create a name for them, and print
|
||||
// thier declarations
|
||||
int i = 0;
|
||||
while (i < mg->nMembers()) {
|
||||
const ContentToken & token = mg->member( i);
|
||||
const ModelGroup * subModel = token.asModelGroup();
|
||||
if (subModel) {
|
||||
// ack -- its an un-named, compound type
|
||||
PrintUnnamedClassDecl (token);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// OK, now print the union
|
||||
prtout ->PrintUnionProlog (currance, "abcd");
|
||||
|
||||
i = 0;
|
||||
while (i < mg->nMembers()) {
|
||||
const ContentToken & token = mg->member( i);
|
||||
const ModelGroup * subModel = token.asModelGroup();
|
||||
if (subModel) {
|
||||
// ack -- its an un-named, compound type
|
||||
PrintUnnamedInstance (token);
|
||||
} else {
|
||||
// put the member elements into the class declaration
|
||||
PrintMember (token);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
prtout ->PrintUnionEpilog (currance, "abcd");
|
||||
}
|
||||
|
||||
void
|
||||
pfxCompoundType :: PrintGroupMembers (const ModelGroup * mg)
|
||||
{
|
||||
|
||||
int i = 0;
|
||||
while (i < mg->nMembers()) {
|
||||
const ContentToken & token = mg->member( i);
|
||||
const ModelGroup * subModel = token.asModelGroup();
|
||||
|
||||
if ( subModel) {
|
||||
if (ModelGroup::orConnector == subModel->connector()) {
|
||||
PrintUnionDecl (token);
|
||||
|
||||
} else {
|
||||
if (ContentToken::none == token.occurrenceIndicator()) {
|
||||
PrintGroupMembers (subModel);
|
||||
} else {
|
||||
// ack -- its an un-named, compound type
|
||||
PrintUnnamedClassDecl (token);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// put the member elements into the class declaration
|
||||
PrintMember (token);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pfxCompoundType :: PrintClass (const ElementType *type)
|
||||
{
|
||||
|
||||
// its not a compound type unless we have a model group.
|
||||
if (ElementDefinition::modelGroup !=
|
||||
type->definition()->declaredContent()) return;
|
||||
|
||||
const ModelGroup * mg;
|
||||
mg = type->definition()->compiledModelGroup()->modelGroup();
|
||||
|
||||
// open the class declaration
|
||||
char * cname = pfxCharify (type->name());
|
||||
char * pname = pfxCapLower (cname);
|
||||
|
||||
prtout->PrintClassProlog (pname);
|
||||
|
||||
PrintGroupMembers (mg);
|
||||
|
||||
prtout->PrintClassEpilog (pname);
|
||||
}
|
||||
|
||||
// ===========================================================
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// pfxCompTypes.h
|
||||
//
|
||||
// FUNCTION:
|
||||
// Parses OFX dtd's
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas March 1998
|
||||
|
||||
#ifndef PFX_COMP_TYPES_H
|
||||
#define PFX_COMP_TYPES_H
|
||||
|
||||
#include "config.h"
|
||||
#include "DtdParser.h"
|
||||
|
||||
#include "pfxBaseTypes.h"
|
||||
#include "pfxUtils.h"
|
||||
|
||||
|
||||
// ===========================================================
|
||||
// handles compund types
|
||||
// IsUnion returns true if its pure-or
|
||||
|
||||
class pfxCompoundType :
|
||||
public pfxBaseType
|
||||
{
|
||||
public:
|
||||
pfxCompoundType (void);
|
||||
char * AddCompoundType (const ElementType *);
|
||||
|
||||
void PrintClass (const ElementType *);
|
||||
|
||||
void PrintMember (const ContentToken &);
|
||||
|
||||
int IsUnion (const ModelGroup *);
|
||||
void PrintUnionDecl (const ContentToken &);
|
||||
void PrintMacroDecl (const ContentToken &);
|
||||
|
||||
char * GetUnnamedClassName (const ContentToken &);
|
||||
void PrintUnnamedClassDecl (const ContentToken &);
|
||||
void PrintUnnamedInstance (const ContentToken &);
|
||||
|
||||
void PrintGroupMembers (const ModelGroup *);
|
||||
|
||||
char * IsClass (char *);
|
||||
|
||||
private:
|
||||
char * classname[MAXVARS];
|
||||
int nclasses;
|
||||
};
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PFX_COMP_TYPES_H */
|
||||
@@ -1,319 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// pfxLangOut.C
|
||||
//
|
||||
// FUNCTION:
|
||||
// Prints the C++ equivalents of the OFX dtd's
|
||||
// The actual implementation of this stuff is very
|
||||
// much of an ugly hack. Sorry.
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas April 1998
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "pfxLangOut.h"
|
||||
#include "pfxUtils.h"
|
||||
|
||||
pfxLangOutput :: pfxLangOutput (void)
|
||||
{
|
||||
dent = 0;
|
||||
prefix = 0x0;
|
||||
}
|
||||
|
||||
// =======================================================
|
||||
pfxOutDecl :: pfxOutDecl (void)
|
||||
{
|
||||
nelts = 0;
|
||||
doing_union = 0;
|
||||
doing_class = 0;
|
||||
nth_union = 0;
|
||||
prefix = strdup("cfx");
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutDecl :: PrintClassProlog (char * decl)
|
||||
{
|
||||
if (0 == doing_class) nth_union = 0;
|
||||
doing_class = 1;
|
||||
|
||||
DENT (dent); printf ("\n\n");
|
||||
DENT (dent); printf ("class cfx%s \n", decl);
|
||||
DENT (dent); printf ("{ \n");
|
||||
DENT (dent); printf (" public:\n");
|
||||
DENT (dent); printf (" cfx%s (void); // constructor \n", decl);
|
||||
DENT (dent); printf (" virtual ~cfx%s (); // destructor \n", decl);
|
||||
DENT (dent); printf ("\n");
|
||||
|
||||
dent +=2;
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutDecl :: PrintClassEpilog (char * decl)
|
||||
{
|
||||
doing_class = 0;
|
||||
dent -=2;
|
||||
DENT (dent); printf ("};\n");
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutDecl :: PrintUnionProlog (occ rance, char * decl)
|
||||
{
|
||||
doing_union = 1;
|
||||
nth_union ++;
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutDecl :: PrintUnionEpilog (occ rance, char * decl)
|
||||
{
|
||||
// not an onion any more, so that PrintMember will revert to normal
|
||||
doing_union = 0;
|
||||
|
||||
// print enumerated type for the union members
|
||||
DENT (dent); printf ("enum Enum%d{\n", nth_union);
|
||||
for (int i=0; i<nelts; i++) {
|
||||
DENT (dent+1); printf ("T_%s,\n", pfxToUpper (varname[i]));
|
||||
}
|
||||
DENT (dent); printf ("};\n\n");
|
||||
|
||||
// print the union declaration
|
||||
DENT (dent); printf ("union Union%d{\n", nth_union);
|
||||
dent ++;
|
||||
for (int i=0; i<nelts; i++) {
|
||||
char * savefix = prefix;
|
||||
prefix = refix[i];
|
||||
PrintMember (currance[i], declaration[i], varname[i]);
|
||||
prefix = savefix;
|
||||
}
|
||||
dent --;
|
||||
DENT (dent); printf ("};\n\n");
|
||||
|
||||
// print the type that will identify the union
|
||||
DENT (dent); printf ("Enum%d utype%d;\n", nth_union, nth_union);
|
||||
|
||||
// print an instance of the union
|
||||
char docl[20];
|
||||
char vor[20];
|
||||
sprintf (docl, "Union%d", nth_union);
|
||||
sprintf (vor, "onion%d", nth_union);
|
||||
char * saveprefix = prefix;
|
||||
prefix = "";
|
||||
PrintMember (rance, docl, vor);
|
||||
prefix = saveprefix;
|
||||
DENT (dent); printf ("\n");
|
||||
|
||||
nelts = 0;
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutDecl :: PrintMember (occ rance, char * decl, char * var)
|
||||
{
|
||||
// for handling a union, just collect the names
|
||||
if (doing_union) {
|
||||
declaration.insert (declaration.begin()+ nelts, strdup (decl));
|
||||
varname.insert (varname.begin()+ nelts, strdup (var));
|
||||
refix.insert (refix.begin()+ nelts, strdup (prefix));
|
||||
currance.insert (currance.begin()+ nelts, rance);
|
||||
nelts ++;
|
||||
return;
|
||||
}
|
||||
|
||||
// for handling ordinary class members, just print them.
|
||||
switch (rance) {
|
||||
case MUST:
|
||||
if (0 < nth_union) {
|
||||
printf ("\n");
|
||||
DENT (dent);
|
||||
printf ("// %s *must* be present \n", decl);
|
||||
}
|
||||
|
||||
DENT (dent);
|
||||
printf ("%s%s *%s; \n", prefix, decl, var);
|
||||
break;
|
||||
|
||||
case OPT:
|
||||
if (0 < nth_union) {
|
||||
printf ("\n");
|
||||
DENT (dent);
|
||||
printf ("// %s may be a null pointer \n", decl);
|
||||
}
|
||||
|
||||
DENT (dent);
|
||||
printf ("%s%s *%s; \n", prefix, decl, var);
|
||||
break;
|
||||
|
||||
case PLUS:
|
||||
if (0 < nth_union) {
|
||||
printf ("\n");
|
||||
DENT (dent);
|
||||
printf ("// %s is a list of one or more items \n", decl);
|
||||
}
|
||||
|
||||
DENT (dent);
|
||||
printf ("%s%s **%s; \n", prefix, decl, var);
|
||||
break;
|
||||
|
||||
case REP:
|
||||
if (0 < nth_union) {
|
||||
printf ("\n");
|
||||
DENT (dent);
|
||||
printf ("// %s is a list of zero or more items \n", decl);
|
||||
}
|
||||
|
||||
DENT (dent);
|
||||
printf ("%s%s **%s; \n", prefix, decl, var);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================
|
||||
|
||||
pfxOutConstructor :: pfxOutConstructor (void)
|
||||
{
|
||||
prefix = strdup ("cfx");
|
||||
doing_union = 0;
|
||||
doing_class = 0;
|
||||
nth_union = 0;
|
||||
done_union = 0;
|
||||
nelts = 0;
|
||||
nest = 0x0;
|
||||
scope [0] = 0x0;
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutConstructor :: PrintClassProlog (char * decl)
|
||||
{
|
||||
if (0 == doing_class) nth_union = 0;
|
||||
|
||||
// check for subclass nesting
|
||||
if (doing_class) {
|
||||
nest = new pfxOutConstructor ();
|
||||
strcpy (nest -> scope, scope);
|
||||
nest->dent = dent;
|
||||
nest->PrintClassProlog (decl);
|
||||
} else {
|
||||
strcpy (classname, prefix);
|
||||
strcat (classname, decl);
|
||||
strcat (scope, classname);
|
||||
strcat (scope, " :: ");
|
||||
}
|
||||
doing_class = 1;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutConstructor :: PrintClassEpilog (char * decl)
|
||||
{
|
||||
// handle subclass nesting
|
||||
if (nest) {
|
||||
nest -> PrintClassEpilog (decl);
|
||||
delete nest;
|
||||
nest = 0x0;
|
||||
}
|
||||
|
||||
doing_class = 0;
|
||||
DENT (dent); printf ("\n\n");
|
||||
DENT (dent); printf ("%s %s (void)\n", scope, classname);
|
||||
DENT (dent); printf ("{\n");
|
||||
dent ++;
|
||||
for (int i=0; i<nelts; i++) {
|
||||
if (override[i][0]) {
|
||||
DENT (dent); printf ("%s", override[i]);
|
||||
} else {
|
||||
PrintMember (currance[i], declaration[i], varname[i]);
|
||||
}
|
||||
}
|
||||
dent --;
|
||||
DENT (dent); printf ("}\n");
|
||||
|
||||
nelts = 0;
|
||||
scope[0] = 0x0;
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutConstructor :: PrintUnionProlog (occ rance, char * decl)
|
||||
{
|
||||
nth_union ++;
|
||||
doing_union = 1;
|
||||
done_union = 0;
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutConstructor :: PrintUnionEpilog (occ rance, char * decl)
|
||||
{
|
||||
doing_union = 0;
|
||||
}
|
||||
|
||||
void
|
||||
pfxOutConstructor :: PrintMember (occ rance, char * decl, char * var)
|
||||
{
|
||||
if (nest) {
|
||||
nest -> PrintMember (rance, decl, var);
|
||||
return;
|
||||
}
|
||||
|
||||
if (doing_class) {
|
||||
if (doing_union) {
|
||||
if (done_union) return;
|
||||
|
||||
char buff[1000];
|
||||
sprintf (buff,
|
||||
"utype%d = T_%s;\n", nth_union, pfxToUpper (decl));
|
||||
override.insert (override.begin()+ nelts, strdup (buff));
|
||||
nelts ++;
|
||||
|
||||
done_union = 1;
|
||||
return;
|
||||
}
|
||||
declaration.insert (declaration.begin()+ nelts, strdup (decl));
|
||||
varname.insert (varname.begin()+ nelts, strdup (var));
|
||||
refix.insert (refix.begin()+ nelts, strdup (prefix));
|
||||
override.insert (override.begin()+ nelts, strdup (""));
|
||||
currance.insert (currance.begin()+ nelts, rance);
|
||||
nelts ++;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (rance) {
|
||||
case MUST:
|
||||
printf ("\n");
|
||||
DENT (dent);
|
||||
printf ("// %s *must* be present \n", decl);
|
||||
|
||||
DENT (dent);
|
||||
printf ("%s = new %s%s; \n", var, prefix, decl);
|
||||
break;
|
||||
|
||||
case OPT:
|
||||
printf ("\n");
|
||||
DENT (dent);
|
||||
printf ("// %s may be a null pointer \n", decl);
|
||||
|
||||
DENT (dent);
|
||||
printf ("%s = 0x0; \n", var);
|
||||
break;
|
||||
|
||||
case PLUS:
|
||||
printf ("\n");
|
||||
DENT (dent);
|
||||
printf ("// %s is a list of one or more items \n", decl);
|
||||
|
||||
DENT (dent);
|
||||
printf ("%s = 0x0; \n", var);
|
||||
break;
|
||||
|
||||
case REP:
|
||||
printf ("\n");
|
||||
DENT (dent);
|
||||
printf ("// %s is a list of zero or more items \n", decl);
|
||||
|
||||
DENT (dent);
|
||||
printf ("%s = 0x0; \n", var);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// pfxLangOut.h
|
||||
//
|
||||
// FUNCTION:
|
||||
// print language specific output
|
||||
// In this case, this generates C++ output
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas April 1998
|
||||
|
||||
#ifndef PFX_COMP_OUT_H
|
||||
#define PFX_COMP_OUT_H
|
||||
|
||||
#include "config.h"
|
||||
#include <vector.h>
|
||||
|
||||
// virtual base class for output
|
||||
// This is the base class that is used by the parser to
|
||||
// generate output.
|
||||
class pfxLangOutput
|
||||
{
|
||||
public:
|
||||
enum occ {
|
||||
MUST, OPT, PLUS, REP };
|
||||
pfxLangOutput (void);
|
||||
virtual void PrintClassProlog (char *hilo) = 0;
|
||||
virtual void PrintClassEpilog (char *hilo) = 0;
|
||||
virtual void PrintUnionProlog (occ, char *hilo) = 0;
|
||||
virtual void PrintUnionEpilog (occ, char *hilo) = 0;
|
||||
|
||||
virtual void PrintMember (occ, char *hilo, char * lo) = 0;
|
||||
|
||||
char * prefix;
|
||||
|
||||
protected:
|
||||
int dent;
|
||||
|
||||
};
|
||||
|
||||
// This class prints the class and union declarations
|
||||
class pfxOutDecl :
|
||||
public pfxLangOutput
|
||||
{
|
||||
public:
|
||||
pfxOutDecl (void);
|
||||
virtual void PrintClassProlog (char *hilo);
|
||||
virtual void PrintClassEpilog (char *hilo);
|
||||
virtual void PrintUnionProlog (occ, char *hilo);
|
||||
virtual void PrintUnionEpilog (occ, char *hilo);
|
||||
|
||||
virtual void PrintMember (occ, char *hilo, char * lo);
|
||||
|
||||
private:
|
||||
short doing_union;
|
||||
short doing_class;
|
||||
int nth_union;
|
||||
|
||||
// When a union has been declared, these are used to store
|
||||
// the members of the union. This is needed because
|
||||
// declaring a union requires several repeats of the data,
|
||||
// each in slightly different form.
|
||||
vector<char *> declaration;
|
||||
vector<char *> varname;
|
||||
vector<char *> refix;
|
||||
vector<occ> currance;
|
||||
int nelts;
|
||||
|
||||
};
|
||||
|
||||
// This class prints the constructors
|
||||
class pfxOutConstructor :
|
||||
public pfxLangOutput
|
||||
{
|
||||
public:
|
||||
pfxOutConstructor (void);
|
||||
virtual void PrintClassProlog (char *hilo);
|
||||
virtual void PrintClassEpilog (char *hilo);
|
||||
virtual void PrintUnionProlog (occ, char *hilo);
|
||||
virtual void PrintUnionEpilog (occ, char *hilo);
|
||||
|
||||
virtual void PrintMember (occ, char *hilo, char * lo);
|
||||
|
||||
private:
|
||||
short doing_union;
|
||||
short doing_class;
|
||||
int nth_union;
|
||||
short done_union;
|
||||
|
||||
pfxOutConstructor *nest;
|
||||
char scope[450];
|
||||
char classname[450];
|
||||
|
||||
// when a class within a class has been dclared, we
|
||||
// can't just create a constructor within the constructor.
|
||||
// Thus, we need to defer the PrintMember() calls until the
|
||||
// call to epilog has shown up.
|
||||
int nelts;
|
||||
vector<char *> declaration;
|
||||
vector<char *> varname;
|
||||
vector<char *> refix;
|
||||
vector<char *> override;
|
||||
vector<occ> currance;
|
||||
|
||||
};
|
||||
|
||||
#endif /* PFX_COMP_OUT_H */
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// utils.C
|
||||
//
|
||||
// FUNCTION:
|
||||
// Handles OFX base types
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas March 1998
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "StringOf.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "pfxUtils.h"
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
namespace SP_NAMESPACE {
|
||||
#endif
|
||||
|
||||
// ===========================================================
|
||||
// convert the string type to an ordinary char *
|
||||
|
||||
char *
|
||||
pfxCharify (const String<short unsigned int> &s)
|
||||
{
|
||||
int len = s.size ();
|
||||
|
||||
char * str = new char [len+1];
|
||||
|
||||
for (int i=0; i<len; i++) {
|
||||
str[i] = s[i];
|
||||
}
|
||||
str[len] = 0x0;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char * pfxToLower (char * str)
|
||||
{
|
||||
int len = strlen (str);
|
||||
|
||||
char * low = new char [len+1];
|
||||
|
||||
for (int i=0; i<len; i++) {
|
||||
low[i] = tolower (str[i]);
|
||||
}
|
||||
low[len] = 0x0;
|
||||
|
||||
return low;
|
||||
}
|
||||
|
||||
char * pfxToUpper (char * str)
|
||||
{
|
||||
int len = strlen (str);
|
||||
|
||||
char * hi = new char [len+1];
|
||||
|
||||
for (int i=0; i<len; i++) {
|
||||
hi[i] = toupper (str[i]);
|
||||
}
|
||||
hi[len] = 0x0;
|
||||
|
||||
return hi;
|
||||
}
|
||||
|
||||
char * pfxCapLower (char * str)
|
||||
{
|
||||
int len = strlen (str);
|
||||
|
||||
char * low = new char [len+1];
|
||||
|
||||
for (int i=0; i<len; i++) {
|
||||
low[i] = tolower (str[i]);
|
||||
}
|
||||
|
||||
if (1 < len) {
|
||||
low[0] = str[0];
|
||||
}
|
||||
|
||||
low[len] = 0x0;
|
||||
|
||||
return low;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
@@ -1,40 +0,0 @@
|
||||
//
|
||||
// FILE:
|
||||
// pfxUtils.h
|
||||
//
|
||||
// FUNCTION:
|
||||
// Assorted utilities
|
||||
//
|
||||
// HISTORY:
|
||||
// Written by Linas Vepstas March 1998
|
||||
|
||||
|
||||
#ifndef PFX_UTILS_H
|
||||
#define PFX_UTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "StringOf.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
namespace SP_NAMESPACE {
|
||||
#endif
|
||||
|
||||
// ===========================================================
|
||||
// convert the string type to an ordinary char *
|
||||
|
||||
char * pfxCharify (const String<short unsigned int> &s);
|
||||
char * pfxToLower (char * str);
|
||||
char * pfxToUpper (char * str);
|
||||
char * pfxCapLower (char * str);
|
||||
|
||||
#define DENT(dent) { for (int bonk=0; bonk<(dent); bonk++) printf (" "); }
|
||||
|
||||
|
||||
#ifdef SP_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PFX_UTILS_H */
|
||||
@@ -1,60 +0,0 @@
|
||||
//
|
||||
// simple.C
|
||||
//
|
||||
// a direct rip-off of James Clark's sample program
|
||||
// for the generic SP parser.
|
||||
//
|
||||
// The next two lines are only to ensure bool gets defined
|
||||
// appropriately.
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "Boolean.h"
|
||||
|
||||
#include "ParserEventGeneratorKit.h"
|
||||
|
||||
|
||||
class OutlineApplication : public SGMLApplication {
|
||||
public:
|
||||
OutlineApplication() : depth_(0) { }
|
||||
|
||||
void PrtStr (const CharString &s) {
|
||||
for (size_t i=0; i<s.len; i++) printf ("%c", s.ptr[2*i]);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
void data (const DataEvent &event) {
|
||||
PrtStr (event.data);
|
||||
}
|
||||
|
||||
void startElement(const StartElementEvent &event) {
|
||||
for (unsigned i = 0; i < depth_; i++) printf (" ");
|
||||
PrtStr (event.gi);
|
||||
depth_++;
|
||||
}
|
||||
|
||||
void endElement(const EndElementEvent &) { depth_--; }
|
||||
|
||||
void startDtd (const StartDtdEvent &event) {
|
||||
PrtStr (event.name);
|
||||
}
|
||||
|
||||
void endDtd(const EndDtdEvent &event) {
|
||||
PrtStr (event.name);
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned depth_;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ParserEventGeneratorKit parserKit;
|
||||
// Use all the arguments after argv[0] as filenames.
|
||||
EventGenerator *egp = parserKit.makeEventGenerator(argc - 1, argv + 1);
|
||||
OutlineApplication app;
|
||||
unsigned nErrors = egp->run(app);
|
||||
delete egp;
|
||||
return nErrors > 0;
|
||||
}
|
||||
Reference in New Issue
Block a user