- xmlfoundationsrc.zip
- XMLFoundation
- Bin
- Errors
- english
- Examples
- c++
- ExATLCOM
- ExCORBA
- ExIndexObjects
- ExObjsFromXML
- Docs
- DynamicObjectsfromXML.html
- ExATLCOM.html
- ExCORBA.html
- Images
- ArrowLeft.gif
- ArrowRight.gif
- ExATLC1.gif
- ExATLC2.gif
- ExATLC3.gif
- gears.gif
- Index.6.gif
- objects.jpg
- ObjFromXML1.jpg
- ObjFromXML10.jpg
- ObjFromXML11.jpg
- ObjFromXML12.jpg
- ObjFromXML13.jpg
- ObjFromXML14.jpg
- ObjFromXML2.jpg
- ObjFromXML3.jpg
- ObjFromXML4.jpg
- ObjFromXML5.jpg
- ObjFromXML6.jpg
- ObjFromXML7.jpg
- ObjFromXML8.jpg
- ObjFromXML9.jpg
- SourceXML.jpg
- vssver.scc
- Java
- ExXMLObjects
- Library
- Build
- makefile.linux
- makefile.sun
- XMLFoundationLib.dsp
- XMLFoundationLib.plg
- inc
- src
- ReadMe.txt
- Tools
- JavaFoundation
- VCppUseThis.dsw
- VCppUseThis.opt
|
// --------------------------------------------------------------------------
// www.UnitedBusinessTechnologies.com
// Copyright (c) 1998 - 2002 All Rights Reserved.
//
// Source in this file is released to the public under the following license:
// --------------------------------------------------------------------------
// This toolkit may be used free of charge for any purpose including corporate
// and academic use. For profit, and Non-Profit uses are permitted.
//
// This source code and any work derived from this source code must retain
// this copyright at the top of each source file.
//
// UBT welcomes any suggestions, improvements or new platform ports.
// email to: XMLFoundation@UnitedBusinessTechnologies.com
// --------------------------------------------------------------------------
#include "FileDataSource.h"
#include "GException.h"
CFileDataSource::~CFileDataSource()
{
}
CFileDataSource::CFileDataSource(const char **ppQueryAttributes)
: CXMLDataSource(ppQueryAttributes,0,0)
{
m_pDirectMemoryBuffer = 0;
m_bProcessed = 0;
m_bIsFile = 0;
}
void CFileDataSource::SetConnectionInfo(const char *szAddress, short nPort)
{
// Port -2 means that the address is a path to a file
if (nPort == -2 && szAddress && szAddress[0])
{
m_strFilePath = szAddress;
m_bIsFile = 1;
}
// Port -1 means that the address is a path to a directory
else if (nPort == -1 && szAddress && szAddress[0])
{
m_strFilePath = szAddress;
if ( !( m_strFilePath.Right(1) == "/" || m_strFilePath.Right(1) == "\\") )
{
#ifdef _WIN32
m_strFilePath += "\\";
#else
m_strFilePath += "/";
#endif
}
}
else
{
CXMLDataSource::SetConnectionInfo(szAddress, nPort);
}
}
void CFileDataSource::SetConnectionInfo(const char *pzXML)
{
m_pDirectMemoryBuffer = pzXML;
}
int CFileDataSource::release(const char *resultFromSend, void *PooledConnection, void *ppUserData)
{
if (m_bProcessed)
{
delete (GString *)ppUserData;
return 1;
}
return 0;
}
const char *CFileDataSource::send(const char *pzProcedureName,
const char *xml,
int nXMLLen,
void *PooledConnection,
void **ppUserData,
const char *pzNamespace)
{
// set to 0 assuming we will not service this request
m_bProcessed = 0;
const char *pReturnXML = 0;
const char *pDir = 0;
// If txml.txt has redirected all client requests to a disk directory
const char *pDebugResponseFile = GetProfile().GetPath("TXML", "DebugXMLServerEmulation",false);
if (pDebugResponseFile && pDebugResponseFile[0])
{
pDir = pDebugResponseFile;
}
// If we're configured to look for responses in a disk directory
if (pDir || m_strFilePath.Length())
{
// calling SetConnectionInfo() overrides txml.txt default
if (m_strFilePath.Length())
{
pDir = m_strFilePath;
}
// create the file name to look for in strInputFile
GString strInputFile = pDir;
if (!m_bIsFile)
{
strInputFile += pzProcedureName;
strInputFile += ".xml";
}
// Allocate storage and keep it in the procedure call, not the DataSource.
GString *strFileBuffer = new GString();
*ppUserData = (void *)strFileBuffer;
strFileBuffer->FromFile((const char *)strInputFile);
pReturnXML = (const char *)*strFileBuffer;
m_bProcessed = 1;// flag for delete
}
// or if we're configured to query from memory, return the location
else if (m_pDirectMemoryBuffer)
{
pReturnXML = m_pDirectMemoryBuffer;
}
return pReturnXML;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here