18 #ifndef _WX_DOCVIEWXMLIO_H_
19 #define _WX_DOCVIEWXMLIO_H_
21 #include "wxartbaseprivate.h"
23 #if wxART2D_USE_XMLPARSE
26 #include <wx/string.h>
45 : m_message( exMessage ), m_row( exRow ), m_column( exColumn ) {}
49 { m_message = other.m_message; }
55 m_message = other.m_message;
63 int getLineNumber()
const {
return m_row; }
64 int getColumnNumber()
const {
return m_column; }
66 wxString getMessage()
const {
return m_message; }
67 void setMessage(
const wxString& exMessage ) { m_message = exMessage; }
92 #include <wx/variant.h>
99 class A2DGENERALDLLEXP a2dAttributeHash_wxImplementation_HashTable;
100 class A2DGENERALDLLEXP a2dAttributeHash_wxImplementation_KeyEx;
101 WX_DECLARE_STRING_HASH_MAP_WITH_DECL( wxString,
a2dAttributeHash,
class A2DGENERALDLLEXP );
137 bool SetAttribute(
const wxString& attributeName,
const wxString& Value );
139 wxString* GetAttribute(
const wxString& attributeName );
141 #if wxART2D_USE_CVGIO
144 #endif //wxART2D_USE_CVGIO
171 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
173 template class A2DGENERALDLLEXP std::allocator<class a2dSmrtPtr<class a2dXMLTag> >;
174 template class A2DGENERALDLLEXP std::allocator< std::_List_nod<class a2dSmrtPtr<class a2dXMLTag>, std::allocator<class a2dSmrtPtr<class a2dXMLTag> > >::_Node >;
175 template class A2DGENERALDLLEXP std::allocator< std::_List_ptr<class a2dSmrtPtr<class a2dXMLTag>, std::allocator<class a2dSmrtPtr<class a2dXMLTag> > >::_Nodeptr >;
176 template class A2DGENERALDLLEXP std::list<class a2dSmrtPtr<class a2dXMLTag> >;
227 virtual void InitializeLoad( );
230 virtual void ResetLoad();
244 virtual int GetCurrentColumnNumber();
255 virtual int GetCurrentLineNumber();
258 wxString GetErrorString();
260 double ParseDouble(
const wxString& buffer,
unsigned int& position ) ;
261 void SkipCommaSpaces(
const wxString& buffer,
unsigned int& position );
262 void SkipSpaces(
const wxString& buffer,
unsigned int& position );
266 virtual void StartElementHnd(
a2dXMLTag* WXUNUSED( tag ) ) {}
267 virtual void EndElementHnd(
const wxString& WXUNUSED( name ) ) {}
268 virtual void CharacterDataHnd(
const wxString& WXUNUSED( text ) ) {}
269 virtual void CommentHnd(
const wxString& WXUNUSED( comment ) ) {}
270 virtual void DefaultHnd(
const wxString& WXUNUSED( def ) ) {}
273 static void BaseStartElementHnd(
void* userData,
const char* name,
const char** atts );
274 static void BaseEndElementHnd(
void* userData,
const char* name );
275 static void BaseCharacterDataHnd(
void* userData,
const char* s,
int len );
276 static void BaseCommentHnd(
void* userData,
const char* data );
277 static void BaseDefaultHnd(
void* userData,
const char* s,
int len );
288 static wxString m_encoding;
290 static wxString m_version;
327 virtual void InitializeLoad( );
330 virtual void ResetLoad();
342 void Require(
const XMLeventType& type, wxString name );
350 wxString GetTagName();
358 wxString GetContent();
412 wxString GetAttributeValue(
const wxString& attrib,
const wxString& defaultv = wxT(
"" ) );
427 wxString RequireAttributeValue(
const wxString& attrib );
438 double GetAttributeValueDouble(
const wxString& attrib,
double defaultv = 0 );
448 double RequireAttributeValueDouble(
const wxString& attrib );
459 int GetAttributeValueInt(
const wxString& attrib,
int defaultv = 0 );
463 {
return ( wxUint16 ) GetAttributeValueInt( attrib, (
int ) defaultv ); }
467 {
return ( wxUint32 ) GetAttributeValueLong( attrib, (
long ) defaultv ); }
477 int RequireAttributeValueInt(
const wxString& attrib );
488 long GetAttributeValueLong(
const wxString& attrib,
long defaultv = 0 );
498 long RequireAttributeValueLong(
const wxString& attrib );
516 bool GetAttributeValueBool(
const wxString& attrib,
bool defaultv =
false );
526 bool RequireAttributeValueBool(
const wxString& attrib );
529 bool HasAttribute(
const wxString& attrib );
535 virtual int GetCurrentColumnNumber();
538 virtual int GetCurrentLineNumber();
549 virtual void StartElementHnd(
a2dXMLTag* tag );
550 virtual void EndElementHnd(
const wxString& name );
551 virtual void CharacterDataHnd(
const wxString& text );
552 virtual void CommentHnd(
const wxString& comment );
553 virtual void DefaultHnd(
const wxString& def );
591 virtual void InitializeSave( );
594 virtual void ResetSave();
613 void EndlWriteString(
const wxString&
string );
630 void WriteStartDocument(
const wxString& version,
const wxString& encoding,
bool standalone );
640 void WriteEndDocument();
654 void WriteStartElement(
const wxString& name,
bool newLine =
true );
668 void WriteStartElementAttributes(
const wxString& name,
bool newLine =
true );
671 void WriteStartElement(
const a2dXMLTag& tag,
bool newLine =
true );
682 void WriteElement(
const wxString& name,
const wxString& content = wxT(
"" ),
bool newLine =
true );
686 template<
typename w_TypeRef>
687 void WriteAttribute(
const wxString& name,
const w_TypeRef& value )
689 wxString error = wxT(
"Wrong start tag" ) + this->m_current->m_tag;
690 wxASSERT_MSG( this->m_current->m_hasattributes , error );
691 *
this << wxT(
" " ) << name << wxT(
"=\"" ) << value << wxT(
"\"" );
694 void WriteAttribute(
const wxString& name,
const size_t& value )
696 wxString error = wxT(
"Wrong start tag" ) + this->m_current->m_tag;
697 wxASSERT_MSG( this->m_current->m_hasattributes , error );
698 *
this << wxT(
" " ) << name << wxT(
"=\"" ) << ( wxUint32 ) value << wxT(
"\"" );
701 void WriteAttributeEnt(
const wxString& name,
const wxString& value );
713 void WriteAttribute(
const wxString& name,
bool value,
bool onlyIfTrue =
false );
723 void WriteEndAttributes(
bool close =
false );
730 void WriteEndElement(
bool newLine =
true );
736 void WriteContent(
const wxString& content );
744 virtual int GetCurrentColumnNumber();
746 virtual int GetCurrentLineNumber();
748 void XmlEncodeStringToStream(
const wxChar*
string,
size_t len = wxString::npos );
751 void SetFormat(
const wxString& format ) { m_format = format; }
757 str.Printf( m_format.c_str(), d );
761 void WriteStringEnt(
const wxString&
string );
775 #if wxUSE_UNICODE && wxWCHAR_T_IS_REAL_TYPE
777 #endif // wxUSE_UNICODE
786 void SetIndent(
int indent ) { m_indent = indent; }
788 int GetIndent() {
return m_indent; }
814 #if wxART2D_USE_CVGIO
841 a2dObject* LoadOneObject( wxObject* parent );
851 wxString m_formatVersion;
872 bool CanSave(
const wxObject* obj = NULL ) {
return true; }
883 #endif //wxART2D_USE_CVGIO
898 virtual void Reset();
905 void WriteCommand(
const wxString& name,
bool close =
true );
907 #if wxUSE_STD_IOSTREAM
908 const wxString& GetString()
const
910 static wxString aap = wxString( m_strstream.str().c_str(), wxConvUTF8 );
914 const wxString GetString()
const {
return m_strstream.GetString(); }
918 bool CanSave(
const wxObject* obj = NULL ) {
return true; }
929 #endif // wxART2D_USE_XMLPARSE
wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
For exceptions thrown while parsing XML files.
(In) Visible property that can be added to Docview Objects.
wxString GetTypeString(const XMLeventType &type)
translate XMLeventType to a string
Input handler for the XML format.
class to map references to objects stored in XML, in order to make the connection later on...
virtual bool Save(a2dDocumentOutputStream &stream, const wxObject *doc)
save a2dCanvasDocument as CVG
wxObject * m_doc
the document to store/load the data found into
a2dXMLTag * m_current
current XML tag
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
a2dSmrtPtrList< a2dXMLTag > m_elements
queue of begin and end elements tags not yet processed
void SetFormat(const wxString &format)
set the format for double to be this
void SetScale(double scale)
Input and output handler for the XmlSer format.
double GetScale()
See GetScale()
a2dIOHandlerXMLException(const wxString &exMessage, int exRow, int exColumn)
Constructor with row and line params.
using a file stream for input, stream the file into a a2dDocument or other object ...
void SetScale(double scale)
a2dXMLTag * GetCurrentTag()
return the tag where the stream is situated
bool m_hasContent
flag to trigger if content was written
wxStringOutputStream a2dDocumentStringOutputStream
string output stream based wxStreams
used in XML parsing to hold one tag and its atributes
int GetDepth()
Returns depth.
XML_Parser m_parser
expat parser
wxObject * m_doc
the document to store/load the data found into
int GetDepth()
Returns depth.
bool m_hasattributes
does the current XMLTag have attributes?
class A2DGENERALDLLEXP a2dAttributeHash
wxString keys to hold attributes
Input and output handler for the XmlSer format.
XMLeventType
Types of XML events when reading files.
bool m_done
true if reached end of document
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
a2dSmrtPtrList< a2dXMLTag > m_elements
queue of begin and end elements tags not yet processed
Input and output handler for the XmlSer format.
using a file stream for output, stream a a2dDocument or other wxObject into a stream.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
wxUint16 GetAttributeValueUint16(const wxString &attrib, wxUint16 defaultv=0)
cast to wxUint16 of GetAttributeValueInt()
a2dXMLTag * m_current
current XML tag
wxInputStream a2dDocumentInputStream
input stream based wxStreams
general modules header files all together.
wxUint32 GetAttributeValueUint32(const wxString &attrib, wxUint32 defaultv=0)
cast to wxUint32 of GetAttributeValueInt()
bool CanSave(const wxObject *obj=NULL)
this handler can also save as CVG
a2dIOHandlerXMLException(const wxString &exMessage)
Constructor.
char * m_buffer
buffer used for passing part of the input stream
XMLeventType m_type
event type
XML_Parser & GetXMLParser()
Returns the XML parser.
Input and output handler for XML alike files.
virtual void WriteDouble(double d)
write a double number.
double GetScale()
See GetScale()
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
wxString m_text
Content of the tag.
void SetIndentSize(int size)
number of spaces in one indentation
void SetFormatVersion(wxString formatVersion)
set version of library or document being parsed for
CloneOptions
options for cloning
bool CanSave(const wxObject *obj=NULL)
this handler can also save as CVG
a2dIOHandlerXMLException(const a2dIOHandlerXMLException &other)
Copy constructor.
wxString GetFormatVersion()
get version of library or document