/usr/include/gdcm-2.6/gdcmParser.h is in libgdcm2-dev 2.6.3-3ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | /*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef GDCMPARSER_H
#define GDCMPARSER_H
#include "gdcmTag.h"
#error do not use
#include "gdcmByteBuffer.h"
#include <fstream> // std::ifstream
namespace gdcm
{
/**
* \brief Parser ala XML_Parser from expat (SAX)
*
* Detailled description here
* \note Simple API for DICOM
*/
class GDCM_EXPORT Parser /*: private IStream*/
{
public:
typedef enum {
NoError,
NoMemoryError,
SyntaxError,
NoElementsError,
TagMismatchError,
DuplicateAttributeError,
JunkAfterDocElementError,
UndefinedEntityError,
UnexpectedStateError
} ErrorType;
Parser() : UserData(0),Buffer(),ErrorCode(NoError) {}
~Parser() {}
// Parse some more of the document. The string s is a buffer containing
// part (or perhaps all) of the document. The number of bytes of s that
// are part of the document is indicated by len. This means that s
// doesn't have to be null terminated. It also means that if len is
// larger than the number of bytes in the block of memory that s points
// at, then a memory fault is likely. The isFinal parameter informs the
// parser that this is the last piece of the document. Frequently, the
// last piece is empty (i.e. len is zero.) If a parse error occurred,
// it returns 0. Otherwise it returns a non-zero value.
bool Parse(const char* s, int len, bool isFinal);
// Set handlers for start and end tags. Attributes are passed to the
// start handler as a pointer to a vector of char pointers. Each
// attribute seen in a start (or empty) tag occupies 2 consecutive places
// in this vector: the attribute name followed by the attribute value.
// These pairs are terminated by a null pointer.
typedef void (*StartElementHandler) (void *userData,
const Tag &tag,
const char *atts[]);
typedef void (*EndElementHandler) (void *userData, const Tag &name);
void SetElementHandler(StartElementHandler start, EndElementHandler end);
// Return what type of error has occurred.
ErrorType GetErrorCode() const;
// Return a string describing the error corresponding to code.
// The code should be one of the enums that can be returned from
// GetErrorCode.
static const char *GetErrorString(ErrorType const &err);
// Return the byte offset of the position.
unsigned long GetCurrentByteIndex() const;
// Miscellaneous functions
// The functions in this section either obtain state information from
// the parser or can be used to dynamically set parser options.
// This sets the user data pointer that gets passed to handlers.
void SetUserData(void *userData);
// This returns the user data pointer that gets passed to handlers.
void * GetUserData() const;
protected:
// This is just like Parse, except in this case expat provides the buffer.
// By obtaining the buffer from expat with the GetBuffer function,
// the application can avoid double copying of the input.
bool ParseBuffer(int len, bool isFinal);
// Obtain a buffer of size len to read a piece of the document into.
// A NULL value is returned if expat can't allocate enough memory for
// this buffer. This has to be called prior to every call to ParseBuffer.
char *GetBuffer(int len);
ErrorType Process();
private:
std::ifstream Stream;
void* UserData;
ByteBuffer Buffer;
ErrorType ErrorCode;
StartElementHandler StartElement;
EndElementHandler EndElement;
};
} // end namespace gdcm
#endif //GDCMPARSER_H
|