diff options
author | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2014-11-13 18:08:18 +0100 |
---|---|---|
committer | Benjamin Paassen <bpaassen@techfak.uni-bielefeld.de> | 2014-11-13 18:08:18 +0100 |
commit | bc4d1cb7dcbbab9bca7f75e2e0c70d54493aae0b (patch) | |
tree | 42f9f023de91129cf82cb77752fe3970e7cf9a25 /src | |
parent | 4771958cf7042d5799eb7591c1abb3d986f8a42a (diff) |
started to implement the CSSParser. First iteration only contains the CSS Specificity.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/utils/CSSParser.cpp | 27 | ||||
-rw-r--r-- | src/core/utils/CSSParser.hpp | 64 |
2 files changed, 91 insertions, 0 deletions
diff --git a/src/core/utils/CSSParser.cpp b/src/core/utils/CSSParser.cpp new file mode 100644 index 0000000..6ac98fa --- /dev/null +++ b/src/core/utils/CSSParser.cpp @@ -0,0 +1,27 @@ +/* + Ousía + Copyright (C) 2014 Benjamin Paaßen, Andreas Stöckel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "CSSParser.hpp" + +namespace ousia { +namespace utils { + + + +} +} diff --git a/src/core/utils/CSSParser.hpp b/src/core/utils/CSSParser.hpp new file mode 100644 index 0000000..4e82371 --- /dev/null +++ b/src/core/utils/CSSParser.hpp @@ -0,0 +1,64 @@ +/* + Ousía + Copyright (C) 2014 Benjamin Paaßen, Andreas Stöckel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _OUSIA_UTILS_CSS_PARSER_HPP_ +#define _OUSIA_UTILS_CSS_PARSER_HPP_ + +#include <istream> +#include <tuple> + +namespace ousia { +namespace utils { + +/* + * The Specificity or Precedence of a CSS RuleSet, which decides which + * rules are applied when different RuleSets contain conflicting information. + * + * The Specificity is calculated using the official W3C recommendation + * http://www.w3.org/TR/CSS2/cascade.html#specificity + * + * Note that we do not need to use the integer 'a', since we do not allow + * local style definitions for single nodes. + */ +struct Specificity { + +int b; +int c; +int d; + +Specificity(int b, int c, int d): b(b), c(c), d(d) {} + +}; + + +bool operator< (const Specificity &x, const Specificity &y){ + return std::tie(x.b, x.c, x.d) < std::tie(y.b, y.c, y.d); +} + +bool operator> (const Specificity &x, const Specificity &y){ + return std::tie(x.b, x.c, x.d) > std::tie(y.b, y.c, y.d); +} + +bool operator== (const Specificity &x, const Specificity &y){ + return std::tie(x.b, x.c, x.d) == std::tie(y.b, y.c, y.d); +} + +} +} + +#endif |