00001
00011
00012 #ifdef _MSC_VER
00013 #include "msdevstudio/MSconfig.h"
00014 #endif
00015
00016 #include "ColorXML.h"
00017
00018 #include "XmlElement.h"
00019
00020 #include "graphics/Color.h"
00021
00022 using std::string;
00023
00024 ColorXML::ColorXML ( XmlController * controller )
00025 : BaseXML ( "Color", controller ),
00026 m_red ( "red" ),
00027 m_green ( "green" ),
00028 m_blue ( "blue" )
00029 {
00030 }
00031
00032 XmlElement * ColorXML::createElement ( const Color & color )
00033 {
00034 XmlElement * tag = BaseXML::createElement ();
00035
00036 tag->setAttribute ( m_red, color.getRed () );
00037 tag->setAttribute ( m_green, color.getGreen () );
00038 tag->setAttribute ( m_blue, color.getBlue () );
00039
00040 return tag;
00041 }
00042
00043 Color * ColorXML::createObject ( const XmlElement * element )
00044 {
00045 int red = 0;
00046 bool ok = element->attribute ( m_red, red );
00047
00048 int green = 0;
00049 ok = element->attribute ( m_green, green );
00050
00051 int blue = 0;
00052 ok = element->attribute ( m_blue, blue );
00053
00054 Color * color = new Color ();
00055 color->setColor ( red, green, blue );
00056
00057 return color;
00058 }