#include "GuiResource.h"
#include "GuiDocument.h"
#include "GuiParserManager.h"
#include "../Controls/GuiApplication.h"
namespace
{
namespace
{
using
namespace
collections
;
using
namespace
controls
;
using
namespace
parsing
;
using
namespace
parsing
::
tabling
;
using
namespace
parsing
::
xml
;
using
namespace
stream
;
class
GuiResourceImageTypeResolver
:
public
,
public
,
private
IGuiResourceTypeResolver_DirectLoadXml
,
private
IGuiResourceTypeResolver_DirectLoadStream
{
public
:
()
override
{
return
L"Image"
;
}
bool
()
override
{
return
true
;
}
bool
()
override
{
return
true
;
}
IGuiResourceTypeResolver_DirectLoadXml
*
()
override
{
return
this
;
}
IGuiResourceTypeResolver_DirectLoadStream
*
()
override
{
return
this
;
}
<
parsing
::
xml
::
>
(
<
>
,
<
>
)
override
{
return
nullptr
;
}
void
(
<
>
,
<
>
,
stream
::
&
)
override
{
auto
=
.
<
>();
stream
::
internal
::
(
);
(
(),
::
);
writer
(
stream
::
&)
fileStream
;
}
<
>
(
<
>
,
<
parsing
::
xml
::
>
,
::
&
)
override
{
.
(
({
},
L"Image should load from file."
));
return
nullptr
;
}
<
>
(
<
>
,
const
&
,
::
&
)
override
{
<
>
=
()->
()->
(
);
if
(
image
)
{
return
new
(
image
,
0
);
}
else
{
.
(
({
},
L"Failed to load file \""
+
+
L"\"."
));
return
nullptr
;
}
}
<
>
ResolveResourcePrecompiled
(
<
>
,
stream
::
&
,
::
&
)
override
{
stream
::
internal
::
(
);
;
reader
(
stream
::
&)
memoryStream
;
auto
=
()->
()->
(
memoryStream
);
if
(
image
)
{
return
new
(
image
,
0
);
}
else
{
.
(
({
},
L"[BINARY] Failed to load an image from binary data in a stream."
));
return
nullptr
;
}
}
};
class
GuiResourceTextTypeResolver
:
public
,
public
,
private
IGuiResourceTypeResolver_DirectLoadXml
,
private
IGuiResourceTypeResolver_DirectLoadStream
{
public
:
()
override
{
return
L"Text"
;
}
bool
()
override
{
return
true
;
}
bool
()
override
{
return
true
;
}
IGuiResourceTypeResolver_DirectLoadXml
*
()
override
{
return
this
;
}
IGuiResourceTypeResolver_DirectLoadStream
*
()
override
{
return
this
;
}
<
parsing
::
xml
::
>
(
<
>
,
<
>
)
override
{
if
(
auto
=
.
<
>())
{
auto
=
<
>();
xmlContent
.
obj
();
auto
=
<
>();
xmlText
.
=
L"Text"
;
xmlText
.
(
xmlContent
);
return
xmlText
;
}
return
0
;
}
void
(
<
>
,
<
>
,
stream
::
&
)
override
{
auto
=
.
<
>();
stream
::
internal
::
(
);
=
obj
();
writer
text
;
}
<
>
(
<
>
,
<
parsing
::
xml
::
>
,
::
&
)
override
{
return
new
(
(
));
}
<
>
(
<
>
,
const
&
,
::
&
)
override
{
;
if
(
(
,
text
))
{
return
new
(
text
);
}
else
{
.
(
({
},
L"Failed to load file \""
+
+
L"\"."
));
return
0
;
}
}
<
>
ResolveResourcePrecompiled
(
<
>
,
stream
::
&
,
::
&
)
override
{
stream
::
internal
::
(
);
;
reader
text
;
return
new
(
text
);
}
};
class
GuiResourceXmlTypeResolver
:
public
,
public
,
private
IGuiResourceTypeResolver_DirectLoadXml
,
private
IGuiResourceTypeResolver_DirectLoadStream
{
public
:
()
override
{
return
L"Xml"
;
}
bool
()
override
{
return
true
;
}
bool
()
override
{
return
true
;
}
IGuiResourceTypeResolver_DirectLoadXml
*
()
override
{
return
this
;
}
IGuiResourceTypeResolver_DirectLoadStream
*
()
override
{
return
this
;
}
<
parsing
::
xml
::
>
(
<
>
,
<
>
)
override
{
if
(
auto
=
.
<
>())
{
auto
=
<
>();
xmlXml
.
=
L"Xml"
;
xmlXml
.
(
obj
);
return
xmlXml
;
}
return
nullptr
;
}
void
(
<
>
,
<
>
,
stream
::
&
)
override
{
auto
=
.
<
>();
=
([&](
&
)
{
(
obj
,
writer
);
});
stream
::
internal
::
(
);
writer
text
;
}
<
>
(
<
>
,
<
parsing
::
xml
::
>
,
::
&
)
override
{
<
>
=
(
).
(
0
);
if
(
root
)
{
<
>
=
new
;
xml
root
;
return
xml
;
}
return
nullptr
;
}
<
>
(
<
>
,
const
&
,
::
&
)
override
{
if
(
auto
=
()->
<
>(
L"XML"
))
{
;
if
(
(
,
text
))
{
return
parser
->Parse({
},
text
,
);
}
else
{
.
(
({
},
L"Failed to load file \""
+
+
L"\"."
));
}
}
return
nullptr
;
}
<
>
ResolveResourcePrecompiled
(
<
>
,
stream
::
&
,
::
&
)
override
{
if
(
auto
=
()->
<
>(
L"XML"
))
{
stream
::
internal
::
(
);
;
reader
text
;
return
parser
->Parse({
},
text
,
);
}
return
nullptr
;
}
};
class
GuiResourceDocTypeResolver
:
public
,
public
,
private
IGuiResourceTypeResolver_IndirectLoad
{
public
:
()
override
{
return
L"Doc"
;
}
bool
()
override
{
return
true
;
}
bool
()
override
{
return
true
;
}
()
override
{
return
L"Xml"
;
}
bool
()
override
{
return
true
;
}
IGuiResourceTypeResolver_IndirectLoad
*
()
override
{
return
this
;
}
<
>
(
<
>
,
<
>
)
override
{
if
(
auto
=
.
<
>())
{
return
obj
();
}
return
nullptr
;
}
<
>
(
<
>
,
<
>
,
::
&
)
override
{
if
(
auto
=
().
<
>())
{
<
>
=
::
(
,
xml
,
,
);
return
model
;
}
return
nullptr
;
}
};
class
GuiResourceTypeResolversPlugin
:
public
,
public
{
public
:
GUI_PLUGIN_NAME(GacUI_Res_TypeResolvers)
vl
::
()
override
{
return
L"GacUI_Res_TypeResolvers"
; }
void
(
vl
::
collections
::
<
>&
)
override
{
GUI_PLUGIN_DEPEND(GacUI_Res_ResourceResolver);
.
(
L"GacUI_Res_ResourceResolver"
);
}
void
()
override
{
IGuiResourceResolverManager
*
=
GetResourceResolverManager
();
manager
->
(
new
GuiResourceImageTypeResolver
);
manager
->
(
new
GuiResourceTextTypeResolver
);
manager
->
(
new
GuiResourceXmlTypeResolver
);
manager
->
(
new
GuiResourceDocTypeResolver
);
}
void
()
override
{
}
};
GUI_REGISTER_PLUGIN(GuiResourceTypeResolversPlugin)
class
GuiRegisterPluginClass_GuiResourceTypeResolversPlugin
{
public
:
GuiRegisterPluginClass_GuiResourceTypeResolversPlugin
() {
vl
::
presentation
::
controls
::
()->
(
new
GuiResourceTypeResolversPlugin
); } }
instance_GuiRegisterPluginClass_GuiResourceTypeResolversPlugin
;
}
}