Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

xmltk.h File Reference

#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <assert.h>
#include "stl.h"
#include "xmltkobj.h"

Go to the source code of this file.

Defines

#define ARRAYSIZE(A)   (sizeof(A)/sizeof((A)[0]))
#define min(a, b)   (((a) < (b)) ? (a) : (b))
#define max(a, b)   (((a) > (b)) ? (a) : (b))
#define ATOMICRELEASE(punk)   { if (punk) { (punk)->Release(); (punk) = NULL; } }
#define myassert(b)

Functions

bool CreateFileStream (RCLIID rcliid, void **ppvObj)
bool CreateMemoryStream (RCLIID rcliid, void **ppvObj)
bool CreateTypeFilter (RCLIID rcliid, void **ppvObj)
bool CreateTSAX2Nil (RCLIID rcliid, void **ppvObj)
IClassFactoryCL * CreateXPathSMFactory (char *pszXPath)
BOOL IsEqualCLIID (const CLIID *riid1, const CLIID *riid2)
bool freadMultiByteUINT (IStream *pstm, unsigned int *puInt)
void fwriteMultiByteUINT (IStream *pstm, unsigned int uInt)
void funread (void *buffer, size_t size, size_t count, FILE *stream)
int mystrcmp (char *psz1, char *psz2)
char * mystrdup (char *psz)
size_t mystrlen (char *psz)
int QueryProcessMemoryUsage ()
void ParseUnknownStream (IStream *pstm, ITSAXContentHandler *pch)
ITSAXContentHandlerCreateStdoutStream (bool bBinary)
IFileStream_CreateFileStream (char *psz)
bool IUnknownCL_SetHandler (IUnknownCL *punk, IUnknownCL *punkHandler)

Variables

ITokenTableg_ptt


Define Documentation

#define ARRAYSIZE      (sizeof(A)/sizeof((A)[0]))
 

Definition at line 25 of file xmltk.h.

Referenced by QueryProcessMemoryUsage(), and fwriteMultiByteUINT().

#define ATOMICRELEASE punk       { if (punk) { (punk)->Release(); (punk) = NULL; } }
 

Definition at line 28 of file xmltk.h.

#define max a,
     (((a) > (b)) ? (a) : (b))
 

Definition at line 27 of file xmltk.h.

Referenced by BXMLOutput::characters().

#define min a,
     (((a) < (b)) ? (a) : (b))
 

Definition at line 26 of file xmltk.h.

#define myassert  
 

Definition at line 68 of file xmltk.h.

Referenced by CTokenMap::AddMapping(), and QueryProcessMemoryUsage().


Function Documentation

bool CreateFileStream RCLIID    rcliid,
void **    ppvObj
 

Definition at line 189 of file filestream.cpp.

Referenced by BXMLOutput::BXMLOutput(), _CreateFileStream(), and _PointToStdout().

00190 {
00191     bool bRet = false;
00192 
00193     CFileStream* pfs = new CFileStream();
00194     if (pfs)
00195     {
00196         bRet = pfs->QueryInterface(riid, ppvObj);
00197         pfs->Release();
00198     }
00199 
00200     return bRet;
00201 }

bool CreateMemoryStream RCLIID    rcliid,
void **    ppvObj
 

Definition at line 250 of file memstream.cpp.

00251 {
00252     bool bRet = false;
00253     CMemoryStream* pms = new CMemoryStream();
00254     if (pms)
00255     {
00256         bRet = pms->QueryInterface(riid, ppvObj);
00257         pms->Release();
00258     }
00259 
00260     return bRet;
00261 }

ITSAXContentHandler* CreateStdoutStream bool    bBinary
 

bool CreateTSAX2Nil RCLIID    rcliid,
void **    ppvObj
 

bool CreateTypeFilter RCLIID    rcliid,
void **    ppvObj
 

IClassFactoryCL* CreateXPathSMFactory char *    pszXPath
 

bool IUnknownCL_SetHandler IUnknownCL *    punk,
IUnknownCL *    punkHandler
 

Definition at line 238 of file util.cpp.

00239 {
00240     ISetHandler* psh;
00241     bool bRet = punk->QueryInterface(&IID_ISetHandler, (void**)&psh);
00242     if (bRet)
00243     {
00244         bRet = psh->SetHandler(punkHandler);
00245         psh->Release();
00246     }
00247     return bRet;
00248 }

BOOL IsEqualCLIID const CLIID   riid1,
const CLIID   riid2
 

Definition at line 9 of file util.cpp.

00010 {
00011     return (memcmp(riid1, riid2, sizeof(*riid1)) == 0);
00012 }

void ParseUnknownStream IStream *    pstm,
ITSAXContentHandler   pch
 

int QueryProcessMemoryUsage  
 

Definition at line 149 of file util.cpp.

00150 {
00151     int cbUsed = 0;
00152 
00153 #ifdef WIN32
00154     myassert(0);    // to be implemented
00155 #else
00156 
00157     char szBuf[4096];
00158     sprintf(szBuf, "/proc/%d/stat", getpid());
00159     szBuf[ARRAYSIZE(szBuf)-1] = 0;
00160 
00161     FILE *pfile = fopen(szBuf, "r");
00162     if (pfile)
00163     {
00164         //
00165         // my psychic powers tell me that the memory usage stat
00166         // is the 23rd token
00167         //
00168         fread(szBuf, sizeof(szBuf)-1, 1, pfile);
00169         szBuf[ARRAYSIZE(szBuf)-1] = 0;
00170 
00171         char *psz = szBuf;
00172         int i;
00173         for (i = 0; i < 22; i++)
00174         {
00175             psz = strchr(psz, ' ') + 1;
00176         }
00177 
00178         cbUsed = bytetok(strtoul(psz, NULL, 10));
00179 
00180         fclose(pfile);
00181     }
00182 #endif
00183 
00184     return cbUsed;
00185 }

IFileStream* _CreateFileStream char *    psz
 

Definition at line 213 of file util.cpp.

00214 {
00215     //
00216     // create a file stream object for this file
00217     //
00218     IFileStream *pstm = NULL;
00219     if (CreateFileStream(&IID_IFileStream, (void**)&pstm))
00220     {
00221         if (psz)
00222         {
00223             if (pstm->OpenFile(psz, "r") == false)
00224             {
00225                 fprintf(stderr, "error opening %s for read\n", psz);
00226                 pstm->Release();
00227                 pstm = NULL;
00228             }
00229         }
00230         else
00231         {
00232             pstm->SetFile(stdin);
00233         }
00234     }
00235     return pstm;
00236 }

bool freadMultiByteUINT IStream *    pstm,
unsigned int *    puInt
 

Definition at line 41 of file util.cpp.

00042 {
00043     *puInt = 0;
00044     int i;
00045 
00046     //
00047     // use a loop to guard against overflow
00048     //
00049     for (i = 0; i < 5; i++)     // 5 = ceil(32/7)
00050     {
00051         int ch = pstm->ReadChar();
00052         if (ch == EOF)
00053         {
00054             return false;
00055         }
00056         else
00057         {
00058             *puInt <<= 7;
00059             *puInt |= (ch & c_chMask);
00060             if (!(ch & c_chContinue))
00061             {
00062                 return true;
00063             }
00064         }
00065     }
00066 
00067     return false;
00068 }

void funread void *    buffer,
size_t    size,
size_t    count,
FILE *    stream
 

Definition at line 70 of file util.cpp.

00071 {
00072     for (int i = count - 1; i >= 0; i--)
00073     {
00074         for (int j = (size/sizeof(char)) - 1; j >= 0; j--)
00075         {
00076             void *bufferT = (void*)((size_t)buffer + (size*i));
00077             int ch = ((char*)bufferT)[j];
00078             ungetc(ch, stream);
00079         }
00080     }
00081 }

void fwriteMultiByteUINT IStream *    pstm,
unsigned int    uInt
 

Definition at line 18 of file util.cpp.

00019 {
00020     unsigned char rgch[5];                          // 5 = ceil(32/7)
00021     int i;
00022 
00023     for (i = 0; i < ARRAYSIZE(rgch); i++)
00024     {
00025         rgch[i] = (uInt & c_chMask) | c_chContinue;
00026         uInt >>= 7;
00027         if (uInt <= 0)
00028         {
00029             break;
00030         }
00031     }
00032 
00033     rgch[0] &= ~c_chContinue;
00034 
00035     for ( ; i >= 0; i--)
00036     {
00037         pstm->WriteChar(rgch[i]);
00038     }
00039 }

int mystrcmp char *    psz1,
char *    psz2
 

Definition at line 100 of file util.cpp.

Referenced by tokeninfo_cmpeq::operator()().

00101 {
00102     if (psz1 == NULL)
00103     {
00104         return psz2 == NULL ? 0 : 1;
00105     }
00106     else if (psz2 == NULL)
00107     {
00108         return -1;
00109     }
00110     else
00111     {
00112         return strcmp(psz1, psz2);
00113     }
00114 }

char* mystrdup char *    psz
 

Definition at line 116 of file util.cpp.

00117 {
00118     if (psz == NULL)
00119     {
00120         return NULL;
00121     }
00122     else
00123     {
00124         return strdup(psz);
00125     }
00126 }

size_t mystrlen char *    psz
 

Definition at line 128 of file util.cpp.

00129 {
00130     if (psz)
00131     {
00132         return strlen(psz);
00133     }
00134     else
00135     {
00136         return 0;
00137     }
00138 }


Variable Documentation

ITokenTable* g_ptt
 

Definition at line 46 of file xmltk.h.


Generated on Sat Dec 22 16:01:56 2001 for XMILLforBinaryFormat by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001