All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Stylish::CSSParser Class Reference

CSS 2.1 parser. More...

#include <Stylish/CSSParser.hpp>

Inheritance diagram for Stylish::CSSParser:
Patterns::NotCopyable

Public Member Functions

float dpi () const
 
Valuable::StyleValue expr (const QByteArray &str)
 
const QString & media () const
 
bool parseSheet (StyleSheet &sheet, const QString &filename, QStringList *files=nullptr, SimpleSelector::Origin origin=SimpleSelector::ORIGIN_AUTHOR)
 Read the declarations from a file to the given StyleSheet. More...
 
bool parseString (StyleSheet &sheet, const QByteArray &str, QStringList *files=nullptr, SimpleSelector::Origin origin=SimpleSelector::ORIGIN_AUTHOR)
 Read declarations from a string to the given StyleSheet. More...
 
QList< Selectorselectors (const QString &str)
 
void setDpi (float dpi)
 
void setMedia (const QString &media)
 

Static Public Member Functions

static float defaultDpi ()
 
static QList< SelectorparseSelectors (const QString &str)
 
static SimpleSelector parseSimpleSelector (const QString &str)
 
static Valuable::StyleValue parseValue (const QByteArray &str)
 
static void setDefaultDpi (float dpi)
 

Detailed Description

CSS 2.1 parser.

Member Function Documentation

float Stylish::CSSParser::dpi ( ) const
Returns
active DPI value
See Also
http://en.wikipedia.org/wiki/Dots_per_inch
Valuable::StyleValue Stylish::CSSParser::expr ( const QByteArray &  str)
Parameters
strone CSS value, without the property name, color or semicolon
Returns
parsed StyleValue object
const QString& Stylish::CSSParser::media ( ) const
inline
Returns
active media type, default value is "screen"
static QList<Selector> Stylish::CSSParser::parseSelectors ( const QString &  str)
static
Parameters
strstring that has any number of selectors, optionally separated by comma
Returns
list of all successfully parsed CSS selectors
bool Stylish::CSSParser::parseSheet ( StyleSheet sheet,
const QString &  filename,
QStringList *  files = nullptr,
SimpleSelector::Origin  origin = SimpleSelector::ORIGIN_AUTHOR 
)

Read the declarations from a file to the given StyleSheet.

Parameters
[out]sheetthe style sheet to update.
[in]filenamethe name of the CSS file.
[out]filesif not null, will contain the list of included files
[in]originused origin with the created declarations
Returns
Return true when the parsing succeeds, and false otherwise.
static SimpleSelector Stylish::CSSParser::parseSimpleSelector ( const QString &  str)
static
Parameters
strstring that has any number of selectors, optionally separated by comma
Returns
first simple selector from the first selector that was parsed successfully
bool Stylish::CSSParser::parseString ( StyleSheet sheet,
const QByteArray &  str,
QStringList *  files = nullptr,
SimpleSelector::Origin  origin = SimpleSelector::ORIGIN_AUTHOR 
)

Read declarations from a string to the given StyleSheet.

Parameters
[out]sheetthe style sheet to update.
[in]strCSS contents in a string
[out]filesif not null, will contain the list of included files
[in]originused origin with the created declarations
Returns
Return true when the parsing succeeds, and false otherwise.
static Valuable::StyleValue Stylish::CSSParser::parseValue ( const QByteArray &  str)
static
Parameters
strone CSS value, without the property name, color or semicolon
Returns
parsed StyleValue object
QList<Selector> Stylish::CSSParser::selectors ( const QString &  str)
Parameters
strstring that has any number of selectors, optionally separated by comma
Returns
list of all successfully parsed CSS selectors
static void Stylish::CSSParser::setDefaultDpi ( float  dpi)
static
Parameters
dpidefault DPI value to use, if there is no explicit DPI value set
void Stylish::CSSParser::setDpi ( float  dpi)
Parameters
dpiexplicit DPI value, overrides the default DPI value
void Stylish::CSSParser::setMedia ( const QString &  media)
inline
Parameters
mediatype to use when parsing, can be any non-empty string
See Also
http://www.w3.org/TR/CSS2/media.html