mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-31 07:12:39 -06:00
Xmlize improvements
git-svn-id: svn://ultimatepp.org/upp/trunk@11089 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
5cef37c34d
commit
171ea3dc4e
2 changed files with 27 additions and 15 deletions
|
|
@ -32,8 +32,8 @@ public:
|
|||
template <class T> XmlIO operator()(const char *tag, T& var);
|
||||
template <class T> XmlIO List(const char *tag, const char *itemtag, T& var);
|
||||
|
||||
template <class T> XmlIO operator()(const char *tag, T& var, const T& def);
|
||||
template <class T> XmlIO List(const char *tag, const char *itemtag, T& var, const T& def);
|
||||
template <class T, class D> XmlIO operator()(const char *tag, T& var, const D& def);
|
||||
template <class T, class D> XmlIO List(const char *tag, const char *itemtag, T& var, const D& def);
|
||||
|
||||
template <class T> XmlIO Attr(const char *id, T& var) {
|
||||
if(IsLoading())
|
||||
|
|
@ -43,7 +43,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
template <class T> XmlIO Attr(const char *id, T& var, T def) {
|
||||
template <class T, class D> XmlIO Attr(const char *id, T& var, const D& def) {
|
||||
if(IsLoading())
|
||||
if(IsNull(node.Attr(id)))
|
||||
var = def;
|
||||
|
|
@ -92,7 +92,7 @@ template <class T> XmlIO XmlIO::List(const char *tag, const char *itemtag, T& va
|
|||
return *this;
|
||||
}
|
||||
|
||||
template <class T> XmlIO XmlIO::operator()(const char *tag, T& var, const T& def)
|
||||
template <class T, class D> XmlIO XmlIO::operator()(const char *tag, T& var, const D& def)
|
||||
{
|
||||
XmlIO n(*this, tag);
|
||||
if(IsLoading() && n.Node().GetCount() == 0 && n.Node().GetAttrCount() == 0)
|
||||
|
|
@ -102,7 +102,7 @@ template <class T> XmlIO XmlIO::operator()(const char *tag, T& var, const T& def
|
|||
return *this;
|
||||
}
|
||||
|
||||
template <class T> XmlIO XmlIO::List(const char *tag, const char *itemtag, T& var, const T& def)
|
||||
template <class T, class D> XmlIO XmlIO::List(const char *tag, const char *itemtag, T& var, const D& def)
|
||||
{
|
||||
XmlIO n(*this, tag);
|
||||
if(IsLoading() && n.Node().GetCount() == 0 && n.Node().GetAttrCount() == 0)
|
||||
|
|
|
|||
|
|
@ -56,18 +56,29 @@ of attribute of current XmlNode (used when storing data to XML).&]
|
|||
[s5;:XmlIO`:`:operator`(`)`(const char`*`,T`&`): [@(0.0.255) template]_<[@(0.0.255) class
|
||||
]_[*@4 T]>_[_^XmlIO^ XmlIO]_[* operator()]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 tag],
|
||||
[*@4 T][@(0.0.255) `&]_[*@3 var])&]
|
||||
[s5;:Upp`:`:XmlIO`:`:operator`(`)`(const char`*`,T`&`,const D`&`): [@(0.0.255) template
|
||||
]_<[@(0.0.255) class]_[*@4 T], [@(0.0.255) class]_[*@4 D]>_[_^Upp`:`:XmlIO^ XmlIO]_[* operato
|
||||
r()]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 tag], [*@4 T][@(0.0.255) `&]_[*@3 var],
|
||||
[@(0.0.255) const]_[*@4 D][@(0.0.255) `&]_[*@3 def])&]
|
||||
[s2;%% Creates subtag of current XmlNode [%-*@3 tag], forms a new XmlIO
|
||||
for it and calls global [* Xmlize ]function with this new XmlIO
|
||||
and [%-*@3 var] as parameters. Common global [* Xmlize ]is a template
|
||||
function that calls [* Xmlize ]method for [%-*@3 var] with new XmlIO
|
||||
as parameter `- that way the [* Xmlize ]can be defined either as
|
||||
global template function specializastion for [%-*@4 T] or as method
|
||||
of [%-*@4 T] (usually easier, but not always possible).&]
|
||||
of [%-*@4 T] (usually easier, but not always possible). [%-*@3 def]
|
||||
parameter can be used to provide default value when retrieving
|
||||
data from XML fails.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:XmlIO`:`:operator`(`)`(const char`*`,const char`*`,T`&`): [@(0.0.255) template]_<[@(0.0.255) c
|
||||
lass]_[*@4 T]>_[_^XmlIO^ XmlIO]_[* operator()]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 ta
|
||||
g], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 itemtag], [*@4 T][@(0.0.255) `&]_[*@3 var])&]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:XmlIO`:`:List`(const char`*`,const char`*`,T`&`,const D`&`): [@(0.0.255) te
|
||||
mplate]_<[@(0.0.255) class]_[*@4 T], [@(0.0.255) class]_[*@4 D]>_[_^Upp`:`:XmlIO^ XmlIO]_[* L
|
||||
ist]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 tag], [@(0.0.255) const]_[@(0.0.255) char]_
|
||||
`*[*@3 itemtag], [*@4 T][@(0.0.255) `&]_[*@3 var], [@(0.0.255) const]_[*@4 D][@(0.0.255) `&]_[*@3 d
|
||||
ef])&]
|
||||
[s5;:Upp`:`:XmlIO`:`:List`(const char`*`,const char`*`,T`&`): [@(0.0.255) template]_<[@(0.0.255) c
|
||||
lass]_[*@4 T]>_[_^Upp`:`:XmlIO^ XmlIO]_[* List]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 t
|
||||
ag], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 itemtag], [*@4 T][@(0.0.255) `&]_[*@3 var])&]
|
||||
[s2;%% Creates subtag of current XmlNode [%-*@3 tag], forms a new XmlIO
|
||||
for it and calls global [* Xmlize ]function with this new XmlIO,
|
||||
[%-*@3 itemtag] and [%-*@3 var] as parameters. Common global [* Xmlize
|
||||
|
|
@ -77,15 +88,16 @@ the [* Xmlize ]can be defined either as global template function
|
|||
specializastion for [%-*@4 T] or as method of [%-*@4 T] (usually
|
||||
easier, but not always possible). [%-*@3 itemtag] is additional
|
||||
parameter that can be used as name of embeded tags when collections
|
||||
of items are Xmlized.&]
|
||||
of items are Xmlized. &]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:XmlIO`:`:Attr`(const char`*`,T`&`): [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 T]>
|
||||
_[_^XmlIO^ XmlIO]_[* Attr]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 id],
|
||||
[*@4 T][@(0.0.255) `&]_[*@3 var])&]
|
||||
[s5;:XmlIO`:`:Attr`(const char`*`,T`&`,T`): [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 T
|
||||
]>_[_^XmlIO^ XmlIO]_[* Attr]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 id],
|
||||
[*@4 T][@(0.0.255) `&]_[*@3 var], [*@4 T]_[*@3 def])&]
|
||||
], [@(0.0.255) class]_[*@4 D]>_[_^Upp`:`:XmlIO^ XmlIO]_[* Attr]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har]_`*[*@3 id], [*@4 T][@(0.0.255) `&]_[*@3 var], [@(0.0.255) const]_[*@4 D][@(0.0.255) `&]_[*@3 d
|
||||
ef])&]
|
||||
[s2;%% When retrieving data, calls global function [@(0.0.255) void
|
||||
][* XmlAttrLoad]([%-*@4 T][%-@(0.0.255) `&][%- _][%-*@3 var], const String`&
|
||||
[* text]) with [* text] set to the value of attribute [%-*@3 id] of
|
||||
|
|
@ -96,8 +108,8 @@ of current XmlNode to the result of global function call String
|
|||
[* XmlAttrStore]([@(0.0.255) const ][%-*@4 T]`& var). Common global
|
||||
Xmlize is a template function that calls [@(0.0.255) void ][* XmlAttrLoad](const
|
||||
String`& [* text]) method for [%-*@3 var]. [%-*@3 def] parameter can
|
||||
be used to provide default value when retrieving data and XML
|
||||
attribute is empty text. Returns `*this.&]
|
||||
be used to provide default value when retrieving data from XML
|
||||
fails. Returns `*this.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:XmlIO`:`:At`(int`): [_^XmlIO^ XmlIO]_[* At]([@(0.0.255) int]_[*@3 i])&]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue