Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
32c35803
Commit
32c35803
authored
Jun 06, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x2t fix linux build
parent
89211eb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
687 additions
and
682 deletions
+687
-682
ASCOfficePPTXFile/Editor/XmlWriter.h
ASCOfficePPTXFile/Editor/XmlWriter.h
+687
-682
No files found.
ASCOfficePPTXFile/Editor/XmlWriter.h
View file @
32c35803
...
@@ -8,744 +8,749 @@
...
@@ -8,744 +8,749 @@
#include "../../Common/DocxFormat/Source/Base/Nullable.h"
#include "../../Common/DocxFormat/Source/Base/Nullable.h"
#include "../../Common/DocxFormat/Source/SystemUtility/File.h"
#include "../../Common/DocxFormat/Source/SystemUtility/File.h"
#if !defined(_WIN32) && !defined(_WIN64)
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
namespace
NSBinPptxRW
namespace
NSBinPptxRW
{
{
static
std
::
wstring
g_bstr_nodeopen
=
L"<"
;
static
std
::
wstring
g_bstr_nodeopen
=
L"<"
;
static
std
::
wstring
g_bstr_nodeclose
=
L">"
;
static
std
::
wstring
g_bstr_nodeclose
=
L">"
;
static
std
::
wstring
g_bstr_nodeopen_slash
=
L"</"
;
static
std
::
wstring
g_bstr_nodeopen_slash
=
L"</"
;
static
std
::
wstring
g_bstr_nodeclose_slash
=
L"/>"
;
static
std
::
wstring
g_bstr_nodeclose_slash
=
L"/>"
;
static
std
::
wstring
g_bstr_node_space
=
L" "
;
static
std
::
wstring
g_bstr_node_space
=
L" "
;
static
std
::
wstring
g_bstr_node_equal
=
L"="
;
static
std
::
wstring
g_bstr_node_equal
=
L"="
;
static
std
::
wstring
g_bstr_node_quote
=
L"
\"
"
;
static
std
::
wstring
g_bstr_node_quote
=
L"
\"
"
;
static
std
::
wstring
g_bstr_boolean_true
=
L"true"
;
static
std
::
wstring
g_bstr_boolean_true
=
L"true"
;
static
std
::
wstring
g_bstr_boolean_false
=
L"false"
;
static
std
::
wstring
g_bstr_boolean_false
=
L"false"
;
static
std
::
wstring
g_bstr_boolean_true2
=
L"1"
;
static
std
::
wstring
g_bstr_boolean_true2
=
L"1"
;
static
std
::
wstring
g_bstr_boolean_false2
=
L"0"
;
static
std
::
wstring
g_bstr_boolean_false2
=
L"0"
;
AVSINLINE
static
double
FABS
(
double
dVal
)
AVSINLINE
static
double
FABS
(
double
dVal
)
{
{
return
(
dVal
>=
0
)
?
dVal
:
-
dVal
;
return
(
dVal
>=
0
)
?
dVal
:
-
dVal
;
}
}
AVSINLINE
static
int
round
(
double
dVal
)
AVSINLINE
static
int
round
(
double
dVal
)
{
{
return
(
int
)(
dVal
+
0.5
);
return
(
int
)(
dVal
+
0.5
);
}
}
class
CStringWriter
class
CStringWriter
{
{
private:
private:
wchar_t
*
m_pData
;
wchar_t
*
m_pData
;
size_t
m_lSize
;
size_t
m_lSize
;
wchar_t
*
m_pDataCur
;
wchar_t
*
m_pDataCur
;
size_t
m_lSizeCur
;
size_t
m_lSizeCur
;
public:
public:
CStringWriter
()
CStringWriter
()
{
{
m_pData
=
NULL
;
m_pData
=
NULL
;
m_lSize
=
0
;
m_lSize
=
0
;
m_pDataCur
=
m_pData
;
m_pDataCur
=
m_pData
;
m_lSizeCur
=
m_lSize
;
m_lSizeCur
=
m_lSize
;
}
}
~
CStringWriter
()
~
CStringWriter
()
{
{
RELEASEMEM
(
m_pData
);
RELEASEMEM
(
m_pData
);
}
}
AVSINLINE
void
AddSize
(
size_t
nSize
)
AVSINLINE
void
AddSize
(
size_t
nSize
)
{
{
if
(
NULL
==
m_pData
)
if
(
NULL
==
m_pData
)
{
{
m_lSize
=
(
std
::
max
)(
nSize
,
(
size_t
)
1024
);
m_lSize
=
(
std
::
max
)(
nSize
,
(
size_t
)
1024
);
m_pData
=
(
wchar_t
*
)
malloc
(
m_lSize
*
sizeof
(
wchar_t
)
+
64
);
m_pData
=
(
wchar_t
*
)
malloc
(
m_lSize
*
sizeof
(
wchar_t
)
+
64
);
m_lSizeCur
=
0
;
m_lSizeCur
=
0
;
m_pDataCur
=
m_pData
;
m_pDataCur
=
m_pData
;
return
;
return
;
}
}
if
((
m_lSizeCur
+
nSize
)
>
m_lSize
)
if
((
m_lSizeCur
+
nSize
)
>
m_lSize
)
{
{
while
((
m_lSizeCur
+
nSize
)
>
m_lSize
)
while
((
m_lSizeCur
+
nSize
)
>
m_lSize
)
{
{
//m_lSize *= 2; - бесконтрольно ..
//m_lSize *= 2; - бесконтрольно ..
m_lSize
+=
(
std
::
max
)(
nSize
,
(
size_t
)
1024
);
m_lSize
+=
(
std
::
max
)(
nSize
,
(
size_t
)
1024
);
}
}
int
size_alloc
=
m_lSize
*
sizeof
(
wchar_t
);
int
size_alloc
=
m_lSize
*
sizeof
(
wchar_t
);
#if defined(_WIN32) || defined (_WIN64)
#if defined(_WIN32) || defined (_WIN64)
wchar_t
*
pRealloc
=
(
wchar_t
*
)
realloc
(
m_pData
,
size_alloc
);
wchar_t
*
pRealloc
=
(
wchar_t
*
)
realloc
(
m_pData
,
size_alloc
);
if
(
NULL
!=
pRealloc
)
if
(
NULL
!=
pRealloc
)
{
{
// реаллок сработал
// реаллок сработал
m_pData
=
pRealloc
;
m_pData
=
pRealloc
;
m_pDataCur
=
m_pData
+
m_lSizeCur
;
m_pDataCur
=
m_pData
+
m_lSizeCur
;
}
}
else
else
#endif
#endif
{
{
wchar_t
*
pMalloc
=
(
wchar_t
*
)
malloc
(
size_alloc
);
wchar_t
*
pMalloc
=
(
wchar_t
*
)
malloc
(
size_alloc
);
memcpy
(
pMalloc
,
m_pData
,
m_lSizeCur
*
sizeof
(
wchar_t
));
memcpy
(
pMalloc
,
m_pData
,
m_lSizeCur
*
sizeof
(
wchar_t
));
free
(
m_pData
);
m_pData
=
pMalloc
;
m_pDataCur
=
m_pData
+
m_lSizeCur
;
}
}
}
free
(
m_pData
);
public:
m_pData
=
pMalloc
;
m_pDataCur
=
m_pData
+
m_lSizeCur
;
}
}
}
public:
AVSINLINE
void
WriteString
(
const
wchar_t
*
pString
,
size_t
&
nLen
)
AVSINLINE
void
WriteString
(
const
wchar_t
*
pString
,
size_t
&
nLen
)
{
{
AddSize
(
nLen
);
AddSize
(
nLen
);
memcpy
(
m_pDataCur
,
pString
,
nLen
*
sizeof
(
wchar_t
));
memcpy
(
m_pDataCur
,
pString
,
nLen
*
sizeof
(
wchar_t
));
m_pDataCur
+=
nLen
;
m_pDataCur
+=
nLen
;
m_lSizeCur
+=
nLen
;
m_lSizeCur
+=
nLen
;
}
}
AVSINLINE
void
WriteString
(
std
::
wstring
&
wString
)
AVSINLINE
void
WriteString
(
std
::
wstring
&
wString
)
{
{
size_t
nLen
=
wString
.
length
();
size_t
nLen
=
wString
.
length
();
WriteString
(
wString
.
c_str
(),
nLen
);
WriteString
(
wString
.
c_str
(),
nLen
);
}
}
#ifdef _WIN32
#ifdef _WIN32
AVSINLINE
void
WriteString
(
_bstr_t
&
bsString
)
AVSINLINE
void
WriteString
(
_bstr_t
&
bsString
)
{
{
size_t
nLen
=
bsString
.
length
();
size_t
nLen
=
bsString
.
length
();
WriteString
(
bsString
.
GetBSTR
(),
nLen
);
WriteString
(
bsString
.
GetBSTR
(),
nLen
);
}
}
#endif // #ifdef _WIN32
#endif // #ifdef _WIN32
AVSINLINE
void
WriteString
(
const
CString
&
sString
)
AVSINLINE
void
WriteString
(
const
CString
&
sString
)
{
{
size_t
nLen
=
(
size_t
)
sString
.
GetLength
();
size_t
nLen
=
(
size_t
)
sString
.
GetLength
();
#ifdef _UNICODE
#ifdef _UNICODE
CString
*
pString
=
const_cast
<
CString
*>
(
&
sString
);
CString
*
pString
=
const_cast
<
CString
*>
(
&
sString
);
WriteString
(
pString
->
GetBuffer
(),
nLen
);
WriteString
(
pString
->
GetBuffer
(),
nLen
);
pString
->
ReleaseBuffer
();
pString
->
ReleaseBuffer
();
#else
#else
CStringW
str
=
(
CStringW
)
sString
;
CStringW
str
=
(
CStringW
)
sString
;
WriteString
(
str
.
GetBuffer
(),
nLen
);
WriteString
(
str
.
GetBuffer
(),
nLen
);
str
.
ReleaseBuffer
();
str
.
ReleaseBuffer
();
#endif
#endif
}
}
AVSINLINE
void
WriteStringXML
(
const
CString
&
strValue
)
AVSINLINE
void
WriteStringXML
(
const
CString
&
strValue
)
{
{
// можно ускорить (см. как сделано в шейпах)
// можно ускорить (см. как сделано в шейпах)
CString
s
=
strValue
;
CString
s
=
strValue
;
s
.
Replace
(
_T
(
"&"
),
_T
(
"&"
));
s
.
Replace
(
_T
(
"&"
),
_T
(
"&"
));
s
.
Replace
(
_T
(
"'"
),
_T
(
"'"
));
s
.
Replace
(
_T
(
"'"
),
_T
(
"'"
));
s
.
Replace
(
_T
(
"<"
),
_T
(
"<"
));
s
.
Replace
(
_T
(
"<"
),
_T
(
"<"
));
s
.
Replace
(
_T
(
">"
),
_T
(
">"
));
s
.
Replace
(
_T
(
">"
),
_T
(
">"
));
s
.
Replace
(
_T
(
"
\"
"
),
_T
(
"""
));
s
.
Replace
(
_T
(
"
\"
"
),
_T
(
"""
));
WriteString
(
s
);
WriteString
(
s
);
}
}
AVSINLINE
void
WriteStringXML
(
const
std
::
wstring
&
wString
)
AVSINLINE
void
WriteStringXML
(
const
std
::
wstring
&
wString
)
{
{
std
::
wstring
buffer
;
std
::
wstring
buffer
;
buffer
.
reserve
(
wString
.
size
());
buffer
.
reserve
(
wString
.
size
());
for
(
size_t
pos
=
0
;
pos
!=
wString
.
size
();
++
pos
)
for
(
size_t
pos
=
0
;
pos
!=
wString
.
size
();
++
pos
)
{
{
switch
(
wString
[
pos
])
switch
(
wString
[
pos
])
{
{
case
'&'
:
buffer
.
append
(
_T
(
"&"
));
break
;
case
'&'
:
buffer
.
append
(
_T
(
"&"
));
break
;
case
'\"'
:
buffer
.
append
(
_T
(
"""
));
break
;
case
'\"'
:
buffer
.
append
(
_T
(
"""
));
break
;
case
'\''
:
buffer
.
append
(
_T
(
"'"
));
break
;
case
'\''
:
buffer
.
append
(
_T
(
"'"
));
break
;
case
'<'
:
buffer
.
append
(
_T
(
"<"
));
break
;
case
'<'
:
buffer
.
append
(
_T
(
"<"
));
break
;
case
'>'
:
buffer
.
append
(
_T
(
">"
));
break
;
case
'>'
:
buffer
.
append
(
_T
(
">"
));
break
;
default:
buffer
.
append
(
&
wString
[
pos
],
1
);
break
;
default:
buffer
.
append
(
&
wString
[
pos
],
1
);
break
;
}
}
}
}
WriteString
(
buffer
);
WriteString
(
buffer
);
}
}
AVSINLINE
size_t
GetCurSize
()
AVSINLINE
size_t
GetCurSize
()
{
{
return
m_lSizeCur
;
return
m_lSizeCur
;
}
}
AVSINLINE
void
Write
(
CStringWriter
&
oWriter
)
AVSINLINE
void
Write
(
CStringWriter
&
oWriter
)
{
{
WriteString
(
oWriter
.
m_pData
,
oWriter
.
m_lSizeCur
);
WriteString
(
oWriter
.
m_pData
,
oWriter
.
m_lSizeCur
);
}
}
AVSINLINE
void
WriteBefore
(
CStringWriter
&
oWriter
)
AVSINLINE
void
WriteBefore
(
CStringWriter
&
oWriter
)
{
{
size_t
nNewS
=
oWriter
.
GetCurSize
();
size_t
nNewS
=
oWriter
.
GetCurSize
();
AddSize
(
nNewS
);
AddSize
(
nNewS
);
memmove
(
m_pData
+
nNewS
,
m_pData
,
m_lSizeCur
*
sizeof
(
wchar_t
));
memmove
(
m_pData
+
nNewS
,
m_pData
,
m_lSizeCur
*
sizeof
(
wchar_t
));
memcpy
(
m_pData
,
oWriter
.
m_pData
,
nNewS
*
sizeof
(
wchar_t
));
memcpy
(
m_pData
,
oWriter
.
m_pData
,
nNewS
*
sizeof
(
wchar_t
));
m_pDataCur
+=
nNewS
;
m_pDataCur
+=
nNewS
;
m_lSizeCur
+=
nNewS
;
m_lSizeCur
+=
nNewS
;
}
}
inline
void
Clear
()
inline
void
Clear
()
{
{
RELEASEMEM
(
m_pData
);
RELEASEMEM
(
m_pData
);
m_pData
=
NULL
;
m_pData
=
NULL
;
m_lSize
=
0
;
m_lSize
=
0
;
m_pDataCur
=
m_pData
;
m_pDataCur
=
m_pData
;
m_lSizeCur
=
0
;
m_lSizeCur
=
0
;
}
}
inline
void
ClearNoAttack
()
inline
void
ClearNoAttack
()
{
{
m_pDataCur
=
m_pData
;
m_pDataCur
=
m_pData
;
m_lSizeCur
=
0
;
m_lSizeCur
=
0
;
}
}
CString
GetData
()
CString
GetData
()
{
{
CString
str
(
m_pData
,
(
int
)
m_lSizeCur
);
CString
str
(
m_pData
,
(
int
)
m_lSizeCur
);
return
str
;
return
str
;
}
}
AVSINLINE
void
AddCharNoCheck
(
const
WCHAR
&
wc
)
AVSINLINE
void
AddCharNoCheck
(
const
WCHAR
&
wc
)
{
{
*
m_pDataCur
++
=
wc
;
*
m_pDataCur
++
=
wc
;
++
m_lSizeCur
;
++
m_lSizeCur
;
}
}
AVSINLINE
void
AddIntNoCheck
(
int
val
)
AVSINLINE
void
AddIntNoCheck
(
int
val
)
{
{
if
(
0
==
val
)
if
(
0
==
val
)
{
{
*
m_pDataCur
++
=
(
WCHAR
)
'0'
;
*
m_pDataCur
++
=
(
WCHAR
)
'0'
;
++
m_lSizeCur
;
++
m_lSizeCur
;
return
;
return
;
}
}
if
(
val
<
0
)
if
(
val
<
0
)
{
{
val
=
-
val
;
val
=
-
val
;
*
m_pDataCur
++
=
(
WCHAR
)
'-'
;
*
m_pDataCur
++
=
(
WCHAR
)
'-'
;
++
m_lSizeCur
;
++
m_lSizeCur
;
}
}
int
len
=
0
;
int
len
=
0
;
int
oval
=
val
;
int
oval
=
val
;
while
(
oval
>
0
)
while
(
oval
>
0
)
{
{
oval
/=
10
;
oval
/=
10
;
++
len
;
++
len
;
}
}
oval
=
1
;
oval
=
1
;
while
(
val
>
0
)
while
(
val
>
0
)
{
{
m_pDataCur
[
len
-
oval
]
=
(
WCHAR
)(
'0'
+
(
val
%
10
));
m_pDataCur
[
len
-
oval
]
=
(
WCHAR
)(
'0'
+
(
val
%
10
));
++
oval
;
++
oval
;
val
/=
10
;
val
/=
10
;
}
}
m_pDataCur
+=
len
;
m_pDataCur
+=
len
;
m_lSizeCur
+=
len
;
m_lSizeCur
+=
len
;
}
}
AVSINLINE
void
AddStringNoCheck
(
const
wchar_t
*
pData
,
const
int
&
len
)
AVSINLINE
void
AddStringNoCheck
(
const
wchar_t
*
pData
,
const
int
&
len
)
{
{
memcpy
(
m_pDataCur
,
pData
,
len
*
sizeof
(
wchar_t
));
memcpy
(
m_pDataCur
,
pData
,
len
*
sizeof
(
wchar_t
));
m_pDataCur
+=
len
;
m_pDataCur
+=
len
;
m_lSizeCur
+=
len
;
m_lSizeCur
+=
len
;
}
}
AVSINLINE
void
AddSpaceNoCheck
()
AVSINLINE
void
AddSpaceNoCheck
()
{
{
*
m_pDataCur
=
WCHAR
(
' '
);
*
m_pDataCur
=
WCHAR
(
' '
);
++
m_pDataCur
;
++
m_pDataCur
;
++
m_lSizeCur
;
++
m_lSizeCur
;
}
}
};
};
class
CXmlWriter
class
CXmlWriter
{
{
public:
public:
CStringWriter
m_oWriter
;
CStringWriter
m_oWriter
;
public:
public:
BYTE
m_lDocType
;
BYTE
m_lDocType
;
LONG
m_lFlag
;
LONG
m_lFlag
;
LONG
m_lGroupIndex
;
LONG
m_lGroupIndex
;
LONG
m_lObjectId
;
LONG
m_lObjectId
;
LONG
m_lObjectIdVML
;
LONG
m_lObjectIdVML
;
LONG
m_lObjectIdOle
;
LONG
m_lObjectIdOle
;
public:
CString
m_strStyleMain
;
CString
m_strAttributesMain
;
CString
m_strNodes
;
CString
m_strOleXlsx
;
IRenderer
*
m_pOOXToVMLRenderer
;
bool
m_bIsTop
;
bool
m_bIsUseOffice2007
;
bool
m_bIsUseOffice2007
;
CString
m_strStyleMain
;
CString
m_strAttributesMain
;
CXmlWriter
()
:
m_oWriter
()
CString
m_strNodes
;
{
IRenderer
*
m_pOOXToVMLRenderer
;
m_lDocType
=
XMLWRITER_DOC_TYPE_PPTX
;
bool
m_bIsTop
;
CString
m_strOleXlsx
;
m_lFlag
=
0
;
public:
m_lGroupIndex
=
0
;
m_lObjectId
=
0
;
CXmlWriter
()
:
m_oWriter
()
m_lObjectIdVML
=
0
;
{
m_lObjectIdOle
=
0
;
m_lDocType
=
XMLWRITER_DOC_TYPE_PPTX
;
m_bIsUseOffice2007
=
false
;
m_lFlag
=
0
;
m_strStyleMain
=
_T
(
""
);
m_lGroupIndex
=
0
;
m_strAttributesMain
=
_T
(
""
);
m_lObjectId
=
0
;
m_strNodes
=
_T
(
""
);
m_lObjectIdVML
=
0
;
m_strOleXlsx
=
_T
(
""
);
m_lObjectIdOle
=
0
;
m_pOOXToVMLRenderer
=
NULL
;
m_bIsUseOffice2007
=
false
;
m_bIsTop
=
false
;
m_strStyleMain
=
_T
(
""
);
}
m_strAttributesMain
=
_T
(
""
);
~
CXmlWriter
()
m_strNodes
=
_T
(
""
);
{
}
m_pOOXToVMLRenderer
=
NULL
;
m_bIsTop
=
false
;
AVSINLINE
CString
GetXmlString
()
m_strOleXlsx
=
L""
;
{
}
return
m_oWriter
.
GetData
();
~
CXmlWriter
()
}
{
AVSINLINE
void
ClearNoAttack
()
}
{
m_oWriter
.
ClearNoAttack
();
AVSINLINE
CString
GetXmlString
()
}
{
AVSINLINE
int
GetSize
()
return
m_oWriter
.
GetData
();
{
}
return
(
int
)
m_oWriter
.
GetCurSize
();
AVSINLINE
void
ClearNoAttack
()
}
{
m_oWriter
.
ClearNoAttack
();
// write value
}
AVSINLINE
void
WriteString
(
const
CString
&
strValue
)
AVSINLINE
int
GetSize
()
{
{
m_oWriter
.
WriteString
(
strValue
);
return
(
int
)
m_oWriter
.
GetCurSize
();
}
}
AVSINLINE
void
WriteStringXML
(
CString
strValue
)
{
// write value
// можно ускорить (см. как сделано в шейпах)
AVSINLINE
void
WriteString
(
const
CString
&
strValue
)
CString
s
=
strValue
;
{
s
.
Replace
(
_T
(
"&"
),
_T
(
"&"
));
m_oWriter
.
WriteString
(
strValue
);
s
.
Replace
(
_T
(
"'"
),
_T
(
"'"
));
}
s
.
Replace
(
_T
(
"<"
),
_T
(
"<"
));
AVSINLINE
void
WriteStringXML
(
CString
strValue
)
s
.
Replace
(
_T
(
">"
),
_T
(
">"
));
{
s
.
Replace
(
_T
(
"
\"
"
),
_T
(
"""
));
// можно ускорить (см. как сделано в шейпах)
m_oWriter
.
WriteString
(
s
);
CString
s
=
strValue
;
}
s
.
Replace
(
_T
(
"&"
),
_T
(
"&"
));
AVSINLINE
void
WriteDouble
(
const
double
&
val
)
s
.
Replace
(
_T
(
"'"
),
_T
(
"'"
));
{
s
.
Replace
(
_T
(
"<"
),
_T
(
"<"
));
CString
str
=
_T
(
""
);
s
.
Replace
(
_T
(
">"
),
_T
(
">"
));
str
.
Format
(
_T
(
"%lf"
),
val
);
s
.
Replace
(
_T
(
"
\"
"
),
_T
(
"""
));
m_oWriter
.
WriteString
(
str
);
m_oWriter
.
WriteString
(
s
);
}
}
AVSINLINE
void
WriteLONG
(
const
long
&
val
)
AVSINLINE
void
WriteDouble
(
const
double
&
val
)
{
{
CString
str
=
_T
(
""
);
CString
str
=
_T
(
""
);
str
.
Format
(
_T
(
"%d"
),
val
);
str
.
Format
(
_T
(
"%lf"
),
val
);
m_oWriter
.
WriteString
(
str
);
m_oWriter
.
WriteString
(
str
);
}
}
AVSINLINE
void
WriteINT
(
const
int
&
val
)
AVSINLINE
void
WriteLONG
(
const
long
&
val
)
{
{
CString
str
=
_T
(
""
);
CString
str
=
_T
(
""
);
str
.
Format
(
_T
(
"%d"
),
val
);
str
.
Format
(
_T
(
"%d"
),
val
);
m_oWriter
.
WriteString
(
str
);
m_oWriter
.
WriteString
(
str
);
}
}
AVSINLINE
void
WriteDWORD
(
const
DWORD
&
val
)
AVSINLINE
void
WriteINT
(
const
int
&
val
)
{
{
CString
str
=
_T
(
""
);
CString
str
=
_T
(
""
);
str
.
Format
(
_T
(
"%u"
),
val
);
str
.
Format
(
_T
(
"%d"
),
val
);
m_oWriter
.
WriteString
(
str
);
m_oWriter
.
WriteString
(
str
);
}
}
AVSINLINE
void
WriteDWORD_hex
(
const
DWORD
&
val
)
AVSINLINE
void
WriteDWORD
(
const
DWORD
&
val
)
{
{
CString
str
=
_T
(
""
);
CString
str
=
_T
(
""
);
str
.
Format
(
_T
(
"%x"
),
val
);
str
.
Format
(
_T
(
"%u"
),
val
);
m_oWriter
.
WriteString
(
str
);
m_oWriter
.
WriteString
(
str
);
}
}
AVSINLINE
void
WriteBool
(
const
bool
&
val
)
AVSINLINE
void
WriteDWORD_hex
(
const
DWORD
&
val
)
{
{
if
(
val
)
CString
str
=
_T
(
""
);
m_oWriter
.
WriteString
(
g_bstr_boolean_true2
);
str
.
Format
(
_T
(
"%x"
),
val
);
else
m_oWriter
.
WriteString
(
str
);
m_oWriter
.
WriteString
(
g_bstr_boolean_false2
);
}
}
AVSINLINE
void
WriteBool
(
const
bool
&
val
)
// write attribute
{
AVSINLINE
void
WriteAttributeCSS
(
const
CString
&
strAttributeName
,
const
CString
&
val
)
if
(
val
)
{
m_oWriter
.
WriteString
(
g_bstr_boolean_true2
);
m_oWriter
.
WriteString
(
strAttributeName
);
else
m_oWriter
.
AddSize
(
15
);
m_oWriter
.
WriteString
(
g_bstr_boolean_false2
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
}
m_oWriter
.
WriteString
(
val
);
// write attribute
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
AVSINLINE
void
WriteAttributeCSS
(
const
CString
&
strAttributeName
,
const
CString
&
val
)
}
{
AVSINLINE
void
WriteAttributeCSS_int
(
const
CString
&
strAttributeName
,
const
int
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
AddSize
(
15
);
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
m_oWriter
.
AddSize
(
15
);
m_oWriter
.
WriteString
(
val
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
m_oWriter
.
AddIntNoCheck
(
val
);
}
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
AVSINLINE
void
WriteAttributeCSS_int
(
const
CString
&
strAttributeName
,
const
int
&
val
)
}
{
AVSINLINE
void
WriteAttributeCSS_double1
(
const
CString
&
strAttributeName
,
const
double
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
AddSize
(
15
);
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
m_oWriter
.
AddSize
(
15
);
m_oWriter
.
AddIntNoCheck
(
val
);
CString
s
=
_T
(
""
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
s
.
Format
(
_T
(
"%.1lf"
),
val
);
}
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
AVSINLINE
void
WriteAttributeCSS_double1
(
const
CString
&
strAttributeName
,
const
double
&
val
)
m_oWriter
.
WriteString
(
s
);
{
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
m_oWriter
.
WriteString
(
strAttributeName
);
}
m_oWriter
.
AddSize
(
15
);
AVSINLINE
void
WriteAttributeCSS_int_pt
(
const
CString
&
strAttributeName
,
const
int
&
val
)
CString
s
=
_T
(
""
);
{
s
.
Format
(
_T
(
"%.1lf"
),
val
);
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
m_oWriter
.
AddSize
(
15
);
m_oWriter
.
WriteString
(
s
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
m_oWriter
.
AddIntNoCheck
(
val
);
}
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
'p'
));
AVSINLINE
void
WriteAttributeCSS_int_pt
(
const
CString
&
strAttributeName
,
const
int
&
val
)
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
't'
));
{
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
m_oWriter
.
WriteString
(
strAttributeName
);
}
m_oWriter
.
AddSize
(
15
);
AVSINLINE
void
WriteAttributeCSS_double1_pt
(
const
CString
&
strAttributeName
,
const
double
&
val
)
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
{
m_oWriter
.
AddIntNoCheck
(
val
);
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
'p'
));
m_oWriter
.
AddSize
(
20
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
't'
));
CString
s
=
_T
(
""
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
s
.
Format
(
_T
(
"%.1lf"
),
val
);
}
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
AVSINLINE
void
WriteAttributeCSS_double1_pt
(
const
CString
&
strAttributeName
,
const
double
&
val
)
m_oWriter
.
WriteString
(
s
);
{
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
'p'
));
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
't'
));
m_oWriter
.
AddSize
(
20
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
CString
s
=
_T
(
""
);
}
s
.
Format
(
_T
(
"%.1lf"
),
val
);
//
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
':'
));
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
CString
&
val
)
m_oWriter
.
WriteString
(
s
);
{
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
'p'
));
m_oWriter
.
WriteString
(
g_bstr_node_space
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
't'
));
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
AddCharNoCheck
(
WCHAR
(
';'
));
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
}
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
//
m_oWriter
.
WriteString
(
val
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
CString
&
val
)
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
{
}
m_oWriter
.
WriteString
(
g_bstr_node_space
);
AVSINLINE
void
WriteAttribute2
(
const
CString
&
strAttributeName
,
const
CString
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_space
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
WriteString
(
val
);
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
}
m_oWriter
.
WriteStringXML
(
val
);
AVSINLINE
void
WriteAttribute2
(
const
CString
&
strAttributeName
,
const
CString
&
val
)
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
{
}
m_oWriter
.
WriteString
(
g_bstr_node_space
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
double
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_space
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
WriteStringXML
(
val
);
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
}
WriteDouble
(
val
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
double
&
val
)
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
{
}
m_oWriter
.
WriteString
(
g_bstr_node_space
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
int
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_space
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
strAttributeName
);
WriteDouble
(
val
);
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
}
WriteINT
(
val
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
int
&
val
)
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
{
}
m_oWriter
.
WriteString
(
g_bstr_node_space
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
bool
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_space
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
strAttributeName
);
WriteINT
(
val
);
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
}
WriteBool
(
val
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
bool
&
val
)
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
{
}
m_oWriter
.
WriteString
(
g_bstr_node_space
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
LONG
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_space
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
strAttributeName
);
WriteBool
(
val
);
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
}
WriteLONG
(
val
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
LONG
&
val
)
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
{
}
m_oWriter
.
WriteString
(
g_bstr_node_space
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
DWORD
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_space
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
strAttributeName
);
WriteLONG
(
val
);
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
}
WriteDWORD
(
val
);
AVSINLINE
void
WriteAttribute
(
const
CString
&
strAttributeName
,
const
DWORD
&
val
)
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
{
}
m_oWriter
.
WriteString
(
g_bstr_node_space
);
AVSINLINE
void
WriteAttributeDWORD_hex
(
const
CString
&
strAttributeName
,
const
DWORD
&
val
)
m_oWriter
.
WriteString
(
strAttributeName
);
{
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_space
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
strAttributeName
);
WriteDWORD
(
val
);
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
}
WriteDWORD_hex
(
val
);
AVSINLINE
void
WriteAttributeDWORD_hex
(
const
CString
&
strAttributeName
,
const
DWORD
&
val
)
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
{
}
m_oWriter
.
WriteString
(
g_bstr_node_space
);
// document methods
m_oWriter
.
WriteString
(
strAttributeName
);
m_oWriter
.
WriteString
(
g_bstr_node_equal
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
WriteDWORD_hex
(
val
);
m_oWriter
.
WriteString
(
g_bstr_node_quote
);
}
// document methods
AVSINLINE
void
WriteNodeBegin
(
CString
strNodeName
,
bool
bAttributed
=
false
)
AVSINLINE
void
WriteNodeBegin
(
CString
strNodeName
,
bool
bAttributed
=
false
)
{
{
m_oWriter
.
WriteString
(
g_bstr_nodeopen
);
m_oWriter
.
WriteString
(
g_bstr_nodeopen
);
m_oWriter
.
WriteString
(
strNodeName
);
m_oWriter
.
WriteString
(
strNodeName
);
if
(
!
bAttributed
)
if
(
!
bAttributed
)
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
}
}
AVSINLINE
void
WriteNodeEnd
(
CString
strNodeName
,
bool
bEmptyNode
=
false
,
bool
bEndNode
=
true
)
AVSINLINE
void
WriteNodeEnd
(
CString
strNodeName
,
bool
bEmptyNode
=
false
,
bool
bEndNode
=
true
)
{
{
if
(
bEmptyNode
)
if
(
bEmptyNode
)
{
{
if
(
bEndNode
)
if
(
bEndNode
)
m_oWriter
.
WriteString
(
g_bstr_nodeclose_slash
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose_slash
);
else
else
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
}
}
else
else
{
{
m_oWriter
.
WriteString
(
g_bstr_nodeopen_slash
);
m_oWriter
.
WriteString
(
g_bstr_nodeopen_slash
);
m_oWriter
.
WriteString
(
strNodeName
);
m_oWriter
.
WriteString
(
strNodeName
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
}
}
}
}
// write node values
// write node values
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
CString
&
val
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
CString
&
val
)
{
{
WriteNodeBegin
(
strNodeName
);
WriteNodeBegin
(
strNodeName
);
WriteString
(
val
);
WriteString
(
val
);
WriteNodeEnd
(
strNodeName
);
WriteNodeEnd
(
strNodeName
);
}
}
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
bool
&
val
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
bool
&
val
)
{
{
WriteNodeBegin
(
strNodeName
);
WriteNodeBegin
(
strNodeName
);
if
(
val
)
if
(
val
)
WriteString
(
_T
(
"1"
));
WriteString
(
_T
(
"1"
));
else
else
WriteString
(
_T
(
"0"
));
WriteString
(
_T
(
"0"
));
WriteNodeEnd
(
strNodeName
);
WriteNodeEnd
(
strNodeName
);
}
}
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
double
&
val
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
double
&
val
)
{
{
WriteNodeBegin
(
strNodeName
);
WriteNodeBegin
(
strNodeName
);
WriteDouble
(
val
);
WriteDouble
(
val
);
WriteNodeEnd
(
strNodeName
);
WriteNodeEnd
(
strNodeName
);
}
}
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
LONG
&
val
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
LONG
&
val
)
{
{
WriteNodeBegin
(
strNodeName
);
WriteNodeBegin
(
strNodeName
);
WriteLONG
(
val
);
WriteLONG
(
val
);
WriteNodeEnd
(
strNodeName
);
WriteNodeEnd
(
strNodeName
);
}
}
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
int
&
val
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
int
&
val
)
{
{
WriteNodeBegin
(
strNodeName
);
WriteNodeBegin
(
strNodeName
);
WriteINT
(
val
);
WriteINT
(
val
);
WriteNodeEnd
(
strNodeName
);
WriteNodeEnd
(
strNodeName
);
}
}
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
DWORD
&
val
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strNodeName
,
const
DWORD
&
val
)
{
{
WriteNodeBegin
(
strNodeName
);
WriteNodeBegin
(
strNodeName
);
WriteDWORD
(
val
);
WriteDWORD
(
val
);
WriteNodeEnd
(
strNodeName
);
WriteNodeEnd
(
strNodeName
);
}
}
AVSINLINE
void
WriteNodeValueDWORD_hex
(
const
CString
&
strNodeName
,
const
DWORD
&
val
)
AVSINLINE
void
WriteNodeValueDWORD_hex
(
const
CString
&
strNodeName
,
const
DWORD
&
val
)
{
{
WriteNodeBegin
(
strNodeName
);
WriteNodeBegin
(
strNodeName
);
WriteDWORD_hex
(
val
);
WriteDWORD_hex
(
val
);
WriteNodeEnd
(
strNodeName
);
WriteNodeEnd
(
strNodeName
);
}
}
bool
SaveToFile
(
CString
strFilePath
,
bool
bEncodingToUTF8
=
true
,
bool
bIsClearNoAttack
=
true
)
bool
SaveToFile
(
CString
strFilePath
,
bool
bEncodingToUTF8
=
true
,
bool
bIsClearNoAttack
=
true
)
{
{
CString
strData
=
m_oWriter
.
GetData
();
CString
strData
=
m_oWriter
.
GetData
();
if
(
!
bEncodingToUTF8
)
if
(
!
bEncodingToUTF8
)
{
{
CFile
oFile
;
CFile
oFile
;
oFile
.
CreateFile
(
strFilePath
);
oFile
.
CreateFile
(
strFilePath
);
oFile
.
WriteFile
((
void
*
)
strData
.
GetBuffer
(),
strData
.
GetLength
());
oFile
.
WriteFile
((
void
*
)
strData
.
GetBuffer
(),
strData
.
GetLength
());
oFile
.
CloseFile
();
oFile
.
CloseFile
();
}
}
else
else
{
{
CDirectory
::
SaveToFile
(
strFilePath
,
strData
);
CDirectory
::
SaveToFile
(
strFilePath
,
strData
);
CFile
oFile
;
CFile
oFile
;
oFile
.
CreateFile
(
strFilePath
);
oFile
.
CreateFile
(
strFilePath
);
CString
strHead
=
_T
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
standalone=
\"
yes
\"
?>"
);
CString
strHead
=
_T
(
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
standalone=
\"
yes
\"
?>"
);
oFile
.
WriteStringUTF8
(
strHead
);
oFile
.
WriteStringUTF8
(
strHead
);
oFile
.
WriteStringUTF8
(
strData
);
oFile
.
WriteStringUTF8
(
strData
);
oFile
.
CloseFile
();
oFile
.
CloseFile
();
}
}
if
(
bIsClearNoAttack
)
if
(
bIsClearNoAttack
)
{
{
m_oWriter
.
ClearNoAttack
();
m_oWriter
.
ClearNoAttack
();
}
}
return
true
;
return
true
;
}
}
public:
public:
// ATTRIBUTES --------------------------------------------------------------------------
// ATTRIBUTES --------------------------------------------------------------------------
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_int
&
value
)
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_int
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteAttribute
(
strName
,
*
value
);
WriteAttribute
(
strName
,
*
value
);
}
}
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_double
&
value
)
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_double
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteAttribute
(
strName
,
*
value
);
WriteAttribute
(
strName
,
*
value
);
}
}
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_string
&
value
)
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_string
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteAttribute
(
strName
,
*
value
);
WriteAttribute
(
strName
,
*
value
);
}
}
AVSINLINE
void
WriteAttribute2
(
const
CString
&
strName
,
const
nullable_string
&
value
)
AVSINLINE
void
WriteAttribute2
(
const
CString
&
strName
,
const
nullable_string
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteAttribute2
(
strName
,
*
value
);
WriteAttribute2
(
strName
,
*
value
);
}
}
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_bool
&
value
)
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_bool
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteAttribute
(
strName
,
*
value
);
WriteAttribute
(
strName
,
*
value
);
}
}
template
<
typename
T
>
template
<
typename
T
>
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_limit
<
T
>&
value
)
AVSINLINE
void
WriteAttribute
(
const
CString
&
strName
,
const
nullable_limit
<
T
>&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteAttribute
(
strName
,
(
*
value
).
get
());
WriteAttribute
(
strName
,
(
*
value
).
get
());
}
}
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
// NODES -------------------------------------------------------------------------------
// NODES -------------------------------------------------------------------------------
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_int
&
value
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_int
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteNodeValue
(
strName
,
*
value
);
WriteNodeValue
(
strName
,
*
value
);
}
}
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_double
&
value
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_double
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteNodeValue
(
strName
,
*
value
);
WriteNodeValue
(
strName
,
*
value
);
}
}
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_string
&
value
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_string
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteNodeValue
(
strName
,
*
value
);
WriteNodeValue
(
strName
,
*
value
);
}
}
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_bool
&
value
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_bool
&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteNodeValue
(
strName
,
*
value
);
WriteNodeValue
(
strName
,
*
value
);
}
}
template
<
typename
T
>
template
<
typename
T
>
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_limit
<
T
>&
value
)
AVSINLINE
void
WriteNodeValue
(
const
CString
&
strName
,
const
nullable_limit
<
T
>&
value
)
{
{
if
(
value
.
IsInit
())
if
(
value
.
IsInit
())
WriteNodeValue
(
strName
,
(
*
value
).
get
);
WriteNodeValue
(
strName
,
(
*
value
).
get
);
}
}
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
// DOCUMENT ----------------------------------------------------------------------------
// DOCUMENT ----------------------------------------------------------------------------
AVSINLINE
void
StartNode
(
const
CString
&
name
)
AVSINLINE
void
StartNode
(
const
CString
&
name
)
{
{
m_oWriter
.
WriteString
(
g_bstr_nodeopen
);
m_oWriter
.
WriteString
(
g_bstr_nodeopen
);
m_oWriter
.
WriteString
(
name
);
m_oWriter
.
WriteString
(
name
);
}
}
AVSINLINE
void
StartAttributes
()
AVSINLINE
void
StartAttributes
()
{
{
// none
// none
}
}
AVSINLINE
void
EndAttributes
()
AVSINLINE
void
EndAttributes
()
{
{
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
}
}
AVSINLINE
void
EndNode
(
const
CString
&
name
)
AVSINLINE
void
EndNode
(
const
CString
&
name
)
{
{
m_oWriter
.
WriteString
(
g_bstr_nodeopen_slash
);
m_oWriter
.
WriteString
(
g_bstr_nodeopen_slash
);
m_oWriter
.
WriteString
(
name
);
m_oWriter
.
WriteString
(
name
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
}
}
#ifdef _WIN32
#ifdef _WIN32
template
<
typename
T
>
template
<
typename
T
>
AVSINLINE
void
WriteArray
(
const
CString
&
strName
,
const
CAtlArray
<
T
>&
arr
)
AVSINLINE
void
WriteArray
(
const
CString
&
strName
,
const
CAtlArray
<
T
>&
arr
)
{
{
size_t
nCount
=
arr
.
GetCount
();
size_t
nCount
=
arr
.
GetCount
();
if
(
0
!=
nCount
)
if
(
0
!=
nCount
)
{
{
StartNode
(
strName
);
StartNode
(
strName
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
arr
[
i
].
toXmlWriter
(
this
);
arr
[
i
].
toXmlWriter
(
this
);
EndNode
(
strName
);
EndNode
(
strName
);
}
}
}
}
#endif //#ifdef _WIN32
#endif //#ifdef _WIN32
template
<
typename
T
>
template
<
typename
T
>
AVSINLINE
void
WriteArray
(
const
CString
&
strName
,
const
std
::
vector
<
T
>&
arr
)
AVSINLINE
void
WriteArray
(
const
CString
&
strName
,
const
std
::
vector
<
T
>&
arr
)
{
{
size_t
nCount
=
arr
.
size
();
size_t
nCount
=
arr
.
size
();
if
(
0
!=
nCount
)
if
(
0
!=
nCount
)
{
{
StartNode
(
strName
);
StartNode
(
strName
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
m_oWriter
.
WriteString
(
g_bstr_nodeclose
);
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
arr
[
i
].
toXmlWriter
(
this
);
arr
[
i
].
toXmlWriter
(
this
);
EndNode
(
strName
);
EndNode
(
strName
);
}
}
}
}
#ifdef _WIN32
#ifdef _WIN32
template
<
typename
T
>
template
<
typename
T
>
AVSINLINE
void
WriteArray2
(
const
CAtlArray
<
T
>&
arr
)
AVSINLINE
void
WriteArray2
(
const
CAtlArray
<
T
>&
arr
)
{
{
size_t
nCount
=
arr
.
GetCount
();
size_t
nCount
=
arr
.
GetCount
();
if
(
0
!=
nCount
)
if
(
0
!=
nCount
)
{
{
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
arr
[
i
].
toXmlWriter
(
this
);
arr
[
i
].
toXmlWriter
(
this
);
}
}
}
}
#endif //#ifdef _WIN32
#endif //#ifdef _WIN32
template
<
typename
T
>
template
<
typename
T
>
AVSINLINE
void
WriteArray2
(
const
std
::
vector
<
T
>&
arr
)
AVSINLINE
void
WriteArray2
(
const
std
::
vector
<
T
>&
arr
)
{
{
size_t
nCount
=
arr
.
size
();
size_t
nCount
=
arr
.
size
();
if
(
0
!=
nCount
)
if
(
0
!=
nCount
)
{
{
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
for
(
size_t
i
=
0
;
i
<
nCount
;
++
i
)
arr
[
i
].
toXmlWriter
(
this
);
arr
[
i
].
toXmlWriter
(
this
);
}
}
}
}
template
<
typename
T
>
template
<
typename
T
>
AVSINLINE
void
Write
(
const
nullable
<
T
>&
val
)
AVSINLINE
void
Write
(
const
nullable
<
T
>&
val
)
{
{
if
(
val
.
is_init
())
if
(
val
.
is_init
())
val
->
toXmlWriter
(
this
);
val
->
toXmlWriter
(
this
);
}
}
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
void
ReplaceString
(
CString
str1
,
CString
str2
)
void
ReplaceString
(
CString
str1
,
CString
str2
)
{
{
// ужасная функция. вызывать ее не надо. не для этого класс писался.
// ужасная функция. вызывать ее не надо. не для этого класс писался.
CString
sCur
=
m_oWriter
.
GetData
();
CString
sCur
=
m_oWriter
.
GetData
();
sCur
.
Replace
(
str1
,
str2
);
sCur
.
Replace
(
str1
,
str2
);
ClearNoAttack
();
ClearNoAttack
();
WriteString
(
sCur
);
WriteString
(
sCur
);
}
}
};
};
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment