-#pragma once\r
-#include "attributes.h"\r
-#include <string>\r
-\r
-namespace litehtml\r
-{\r
- class property_value\r
- {\r
- public:\r
- tstring m_value;\r
- bool m_important;\r
-\r
- property_value()\r
- {\r
- m_important = false;\r
- }\r
- property_value(const tchar_t* val, bool imp)\r
- {\r
- m_important = imp;\r
- m_value = val;\r
- }\r
- property_value(const property_value& val)\r
- {\r
- m_value = val.m_value;\r
- m_important = val.m_important;\r
- }\r
-\r
- property_value& operator=(const property_value& val)\r
- {\r
- m_value = val.m_value;\r
- m_important = val.m_important;\r
- return *this;\r
- }\r
- };\r
-\r
- typedef std::map<tstring, property_value> props_map;\r
-\r
- class style\r
- {\r
- public:\r
- typedef std::shared_ptr<style> ptr;\r
- typedef std::vector<style::ptr> vector;\r
- private:\r
- props_map m_properties;\r
- static string_map m_valid_values;\r
- public:\r
- style();\r
- style(const style& val);\r
- virtual ~style();\r
-\r
- void operator=(const style& val)\r
- {\r
- m_properties = val.m_properties;\r
- }\r
-\r
- void add(const tchar_t* txt, const tchar_t* baseurl)\r
- {\r
- parse(txt, baseurl);\r
- }\r
-\r
- void add_property(const tchar_t* name, const tchar_t* val, const tchar_t* baseurl, bool important);\r
-\r
- const tchar_t* get_property(const tchar_t* name) const\r
- {\r
- if(name)\r
- {\r
- props_map::const_iterator f = m_properties.find(name);\r
- if(f != m_properties.end())\r
- {\r
- return f->second.m_value.c_str();\r
- }\r
- }\r
- return 0;\r
- }\r
-\r
- void combine(const litehtml::style& src);\r
- void clear()\r
- {\r
- m_properties.clear();\r
- }\r
-\r
- private:\r
- void parse_property(const tstring& txt, const tchar_t* baseurl);\r
- void parse(const tchar_t* txt, const tchar_t* baseurl);\r
- void parse_short_border(const tstring& prefix, const tstring& val, bool important);\r
- void parse_short_background(const tstring& val, const tchar_t* baseurl, bool important);\r
- void parse_short_font(const tstring& val, bool important);\r
- void add_parsed_property(const tstring& name, const tstring& val, bool important);\r
- void remove_property(const tstring& name, bool important);\r
- };\r
-}
\ No newline at end of file
+#ifndef LH_STYLE_H
+#define LH_STYLE_H
+
+#include "attributes.h"
+#include <string>
+
+namespace litehtml
+{
+ class property_value
+ {
+ public:
+ tstring m_value;
+ bool m_important;
+
+ property_value()
+ {
+ m_important = false;
+ }
+ property_value(const tchar_t* val, bool imp)
+ {
+ m_important = imp;
+ m_value = val;
+ }
+ property_value(const property_value& val)
+ {
+ m_value = val.m_value;
+ m_important = val.m_important;
+ }
+
+ property_value& operator=(const property_value& val)
+ {
+ m_value = val.m_value;
+ m_important = val.m_important;
+ return *this;
+ }
+ };
+
+ typedef std::map<tstring, property_value> props_map;
+
+ class style
+ {
+ public:
+ typedef std::shared_ptr<style> ptr;
+ typedef std::vector<style::ptr> vector;
+ private:
+ props_map m_properties;
+ static string_map m_valid_values;
+ public:
+ style();
+ style(const style& val);
+ virtual ~style();
+
+ void operator=(const style& val)
+ {
+ m_properties = val.m_properties;
+ }
+
+ void add(const tchar_t* txt, const tchar_t* baseurl)
+ {
+ parse(txt, baseurl);
+ }
+
+ void add_property(const tchar_t* name, const tchar_t* val, const tchar_t* baseurl, bool important);
+
+ const tchar_t* get_property(const tchar_t* name) const
+ {
+ if(name)
+ {
+ props_map::const_iterator f = m_properties.find(name);
+ if(f != m_properties.end())
+ {
+ return f->second.m_value.c_str();
+ }
+ }
+ return 0;
+ }
+
+ void combine(const litehtml::style& src);
+ void clear()
+ {
+ m_properties.clear();
+ }
+
+ private:
+ void parse_property(const tstring& txt, const tchar_t* baseurl);
+ void parse(const tchar_t* txt, const tchar_t* baseurl);
+ void parse_short_border(const tstring& prefix, const tstring& val, bool important);
+ void parse_short_background(const tstring& val, const tchar_t* baseurl, bool important);
+ void parse_short_font(const tstring& val, bool important);
+ void add_parsed_property(const tstring& name, const tstring& val, bool important);
+ void remove_property(const tstring& name, bool important);
+ };
+}
+
+#endif // LH_STYLE_H