2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "interfaces/info/InfoBool.h"
19 // forward definitions
23 class CSkinVariableString
;
33 \brief Clear all include components (defaults, constants, variables, expressions and includes)
38 \brief Load all include components(defaults, constants, variables, expressions and includes)
39 from the main entrypoint \code{file}. Flattens nested expressions and expressions in variable
40 conditions after loading all other included files.
42 \param file the file to load
44 void Load(const std::string
&file
);
47 \brief Resolve all include components (defaults, constants, variables, expressions and includes)
48 for the given \code{node}. Place the conditions specified for <include> elements in \code{includeConditions}.
50 \param node the node from where we start to resolve the include components
51 \param includeConditions a map that holds the conditions for resolved includes
53 void Resolve(TiXmlElement
*node
, std::map
<INFO::InfoPtr
, bool>* includeConditions
= NULL
);
56 \brief Create a skin variable for the given \code{name} within the given \code{context}.
58 \param name the name of the skin variable
59 \param context the context where the variable is created in
62 const INFO::CSkinVariableString
* CreateSkinVariable(const std::string
& name
, int context
);
65 enum ResolveParamsResult
69 SINGLE_UNDEFINED_PARAM_RESOLVED
73 \brief Load all include components (defaults, constants, variables, expressions and includes)
74 from the given \code{file}.
76 \param file the file to load
77 \return true if the file was loaded otherwise false
79 bool Load_Internal(const std::string
&file
);
81 bool HasLoaded(const std::string
&file
) const;
83 void LoadDefaults(const TiXmlElement
*node
);
84 void LoadIncludes(const TiXmlElement
*node
);
85 void LoadVariables(const TiXmlElement
*node
);
86 void LoadConstants(const TiXmlElement
*node
);
87 void LoadExpressions(const TiXmlElement
*node
);
90 \brief Resolve all expressions containing other expressions to a single evaluatable expression.
92 void FlattenExpressions();
95 \brief Expand any expressions nested in this expression.
97 \param expression the expression to flatten
98 \param resolved list of already evaluated expression names, to avoid expanding circular references
100 void FlattenExpression(std::string
&expression
, const std::vector
<std::string
> &resolved
);
103 \brief Resolve all variable conditions containing expressions to a single evaluatable condition.
105 void FlattenSkinVariableConditions();
107 void SetDefaults(TiXmlElement
*node
);
108 void ResolveIncludes(TiXmlElement
*node
, std::map
<INFO::InfoPtr
, bool>* xmlIncludeConditions
= NULL
);
109 void ResolveConstants(TiXmlElement
*node
);
110 void ResolveExpressions(TiXmlElement
*node
);
112 typedef std::map
<std::string
, std::string
> Params
;
113 static void InsertNested(TiXmlElement
* controls
, TiXmlElement
* include
, TiXmlElement
* node
);
114 static bool GetParameters(const TiXmlElement
*include
, const char *valueAttribute
, Params
& params
);
115 static void ResolveParametersForNode(TiXmlElement
*node
, const Params
& params
);
116 static ResolveParamsResult
ResolveParameters(const std::string
& strInput
, std::string
& strOutput
, const Params
& params
);
118 std::string
ResolveConstant(const std::string
&constant
) const;
119 std::string
ResolveExpressions(const std::string
&expression
) const;
121 std::vector
<std::string
> m_files
;
122 std::map
<std::string
, std::pair
<TiXmlElement
, Params
>> m_includes
;
123 std::map
<std::string
, TiXmlElement
> m_defaults
;
124 std::map
<std::string
, TiXmlElement
> m_skinvariables
;
125 std::map
<std::string
, std::string
> m_constants
;
126 std::map
<std::string
, std::string
> m_expressions
;
128 std::set
<std::string
> m_constantAttributes
;
129 std::set
<std::string
> m_constantNodes
;
131 std::set
<std::string
> m_expressionAttributes
;
132 std::set
<std::string
> m_expressionNodes
;