2005-05-28 00:45:31 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Initial
|
|
|
|
* Developer's Public License Version 1.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
|
|
|
* http://www.ibphoenix.com/idpl.html.
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on
|
|
|
|
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
|
|
|
|
* express or implied. See the License for the specific
|
|
|
|
* language governing rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The contents of this file or any work derived from this file
|
|
|
|
* may not be distributed under any other license whatsoever
|
|
|
|
* without the express prior written permission of the original
|
|
|
|
* author.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* The Original Code was created by James A. Starkey for IBPhoenix.
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997 - 2000, 2001, 2003 James A. Starkey
|
|
|
|
* Copyright (c) 1997 - 2000, 2001, 2003 Netfrastructure, Inc.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Element.h: interface for the Element class.
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#if !defined(AFX_ELEMENT_H__36AF5EE7_6842_4000_B3C5_DB8DECEC79B7__INCLUDED_)
|
|
|
|
#define AFX_ELEMENT_H__36AF5EE7_6842_4000_B3C5_DB8DECEC79B7__INCLUDED_
|
|
|
|
|
2005-06-21 12:26:56 +02:00
|
|
|
#if defined _MSC_VER && _MSC_VER >= 1000
|
2005-05-28 00:45:31 +02:00
|
|
|
#pragma once
|
|
|
|
#endif // _MSC_VER > 1000
|
|
|
|
|
|
|
|
#include "JString.h"
|
|
|
|
|
|
|
|
START_NAMESPACE
|
|
|
|
|
|
|
|
class Stream;
|
|
|
|
class InputStream;
|
|
|
|
|
|
|
|
class Element
|
|
|
|
{
|
|
|
|
public:
|
2008-04-20 13:46:02 +02:00
|
|
|
explicit Element(JString elementName);
|
|
|
|
Element (JString elementName, JString elementValue);
|
|
|
|
virtual ~Element();
|
|
|
|
|
|
|
|
void addChild (Element *child);
|
|
|
|
Element* addChild (JString name);
|
|
|
|
|
|
|
|
void addAttribute (Element *child);
|
2005-05-28 00:45:31 +02:00
|
|
|
void addAttribute (JString name);
|
2008-04-20 13:46:02 +02:00
|
|
|
Element* addAttribute (JString name, JString value);
|
|
|
|
Element* addAttribute (JString name, int value);
|
|
|
|
|
|
|
|
Element* findChild (const char *name, const char *attribute, const char *value);
|
2008-04-19 11:40:19 +02:00
|
|
|
void gen (int level, Stream *stream) const;
|
2005-05-28 00:45:31 +02:00
|
|
|
void setSource (int line, InputStream *stream);
|
|
|
|
const char* getAttributeValue (const char *name, const char *defaultValue);
|
|
|
|
const char* getAttributeValue (const char *name);
|
2007-04-18 13:02:41 +02:00
|
|
|
const char* getAttributeName (int position) const;
|
2005-05-28 00:45:31 +02:00
|
|
|
Element* findChildIgnoreCase (const char *name);
|
2008-04-19 11:40:19 +02:00
|
|
|
void indent (int level, Stream *stream) const;
|
|
|
|
void genXML (int level, Stream *stream) const;
|
2005-05-28 00:45:31 +02:00
|
|
|
Element* findAttribute (const char *name);
|
2008-04-19 11:40:19 +02:00
|
|
|
const Element* findAttribute (const char *name) const;
|
2007-04-18 13:02:41 +02:00
|
|
|
Element* findAttribute (int seq);
|
|
|
|
const Element* findAttribute (int seq) const;
|
2005-05-28 00:45:31 +02:00
|
|
|
Element* findChild (const char *name);
|
2008-04-19 11:40:19 +02:00
|
|
|
const Element* findChild (const char *name) const;
|
|
|
|
void print (int level) const;
|
2008-04-20 13:46:02 +02:00
|
|
|
const Element* getAttributes() const { return attributes; }
|
2005-05-28 00:45:31 +02:00
|
|
|
|
|
|
|
JString name;
|
|
|
|
JString value;
|
2008-04-20 13:46:02 +02:00
|
|
|
|
2005-05-28 00:45:31 +02:00
|
|
|
Element *sibling;
|
|
|
|
Element *children;
|
2008-04-20 13:46:02 +02:00
|
|
|
|
2005-05-28 00:45:31 +02:00
|
|
|
int lineNumber;
|
|
|
|
int numberLines;
|
|
|
|
InputStream *inputStream;
|
|
|
|
static int analyseText(const char* text);
|
2008-04-19 11:40:19 +02:00
|
|
|
void putQuotedText(const char* text, Stream* stream) const;
|
2005-05-28 00:45:31 +02:00
|
|
|
static int analyzeData(int length, const UCHAR* data);
|
2008-04-20 13:46:02 +02:00
|
|
|
private:
|
|
|
|
void init(JString elementName);
|
|
|
|
JString innerText;
|
|
|
|
//JString outerText;
|
|
|
|
Element *parent; // assigned but never used.
|
|
|
|
Element *attributes;
|
2005-05-28 00:45:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
END_NAMESPACE
|
|
|
|
|
|
|
|
#endif // !defined(AFX_ELEMENT_H__36AF5EE7_6842_4000_B3C5_DB8DECEC79B7__INCLUDED_)
|