Go to the documentation of this file.
12 #ifndef ZYPP_MISC_HELIXHELPERS_H
13 #define ZYPP_MISC_HELIXHELPERS_H
19 #include <libxml/parser.h>
20 #include <libxml/xmlmemory.h>
24 #include <string_view>
30 template <
typename Tp>
48 std::string_view
name()
const {
return (std::string_view((
const char *)
_node->name)); }
49 xmlElementType
type()
const {
return (
_node->type); }
52 std::optional<XmlNode>
next()
const {
return (
_node->next == NULL ? std::optional<XmlNode>() :
XmlNode (
_node->next)); }
53 std::optional<XmlNode>
children()
const {
return (
_node->xmlChildrenNode == NULL ? std::optional<XmlNode>() :
XmlNode (
_node->xmlChildrenNode)); }
57 bool equals (
const std::string_view & n)
const {
return (strncasecmp (
name().data(), n.data(), n.length() ) == 0); }
61 std::map<std::string, std::string> res;
63 if ( !
attr->children )
66 res.insert( std::make_pair( std::string((
char *)
attr->name), std::string( (
char *)value.
value() ) ) );
75 *buf = xmlNodeGetContent (
_node);
77 ret = std::string ((
const char *)buf.
value());
82 std::string
getProp (
const std::string &
name,
const std::string & deflt =
"")
const {
86 *ret = xmlGetProp (
_node, (
const xmlChar *)
name.c_str());
89 gs = std::string ((
const char *)ret.
value());
108 *xml_s = xmlGetProp(
_node, (
const xmlChar *)
name.c_str());
110 target = std::string ((
const char *)xml_s.
value());
114 child =
_node->xmlChildrenNode;
117 if (strcasecmp((
const char *)(child->name),
name.c_str()) == 0) {
118 xml_s = xmlNodeGetContent(child);
120 target = std::string ((
const char *)xml_s.
value());
139 auto architecture = setup.
getProp(
"arch" );
140 if ( !architecture.empty() )
147 if ( err ) *err =
zypp::str::Str() <<
"Bad architecture '" << architecture <<
"' in <setup...>";
155 if ( !
node->isElement() ) {
160 #define if_SolverFlag( N ) if ( node->equals( #N ) ) { target.N = true; }
177 else if (
node->equals(
"focus") ) {
180 else if (
node->equals(
"system") ) {
185 node->getProp(
"file")
188 else if (
node->equals(
"hardwareInfo") ) {
191 else if (
node->equals(
"modalias") ) {
194 else if (
node->equals(
"multiversion") ) {
197 else if (
node->equals (
"channel")) {
198 std::string name =
node->getProp(
"name");
199 std::string file =
node->getProp(
"file");
200 std::string type =
node->getProp(
"type");
203 std::string priority =
node->getProp(
"priority");
204 if ( !priority.empty() ) {
205 prio = zypp::str::strtonum<unsigned>( priority );
215 else if (
node->equals(
"source") )
217 std::string
url =
node->getProp(
"url");
218 std::string alias =
node->getProp(
"name");
226 else if (
node->equals(
"force-install") )
229 node->getProp(
"channel"),
230 node->getProp(
"package"),
231 node->getProp(
"kind")
234 else if (
node->equals(
"mediaid") )
238 else if (
node->equals(
"arch") ) {
239 MIL <<
"<arch...> deprecated, use <setup arch=\"...\"> instead" << std::endl;
240 std::string architecture =
node->getProp(
"name");
241 if ( architecture.empty() ) {
242 ERR <<
"Property 'name=' in <arch.../> missing or empty" << std::endl;
245 MIL <<
"Setting architecture to '" << architecture <<
"'" << std::endl;
249 else if (
node->equals(
"locale") )
252 std::string fate =
node->getProp(
"fate");
254 ERR <<
"Bad or missing name in <locale...>" << std::endl;
256 else if ( fate ==
"added" ) {
259 else if ( fate ==
"removed" ) {
266 else if (
node->equals(
"autoinst") ) {
269 else if (
node->equals(
"systemCheck") ) {
272 else if (
node->equals(
"setlicencebit") ) {
276 ERR <<
"Unrecognized tag '" <<
node->name() <<
"' in setup" << std::endl;
286 const auto & content =
node.getContent();
287 if ( !content.empty() ) {
288 testcaseNode.
value = content;
292 for (
auto childNode =
node.children(); childNode; childNode = childNode->next() ) {
293 auto testNode = std::make_shared<zypp::misc::testcase::TestcaseTrial::Node>();
296 testcaseNode.
children.push_back( testNode );
305 if (!
node->isElement()) {
312 target.
nodes.push_back( testcaseNode );
AutoXmlFree(Tp *ptr_r=nullptr)
base::SetTracker< LocaleSet > localesTracker
std::optional< RepoData > systemRepo
std::string getContent(void) const
Base class for Exception.
bool equals(const std::string_view &n) const
std::string_view name() const
std::ostream & node(std::ostream &out_r, const std::string &name_r, Node::Attr attr_r)
const set_type & added() const
Return the set of added items.
const set_type & current() const
Return the current set.
std::vector< ForceInstall > forceInstallTasks
std::map< std::string, std::string > properties
std::map< std::string, std::string > getAllProps() const
XmlNode(const xmlNodePtr node)
xmlElementType type() const
std::optional< XmlNode > next() const
sat::StringQueue autoinstalled
Access to the sat-pools string space.
bool getValue(const std::string &name, T &target) const
bool isElement(void) const
T getValue(const std::string &name, const T &deflt) const
std::vector< Node > nodes
std::string getProp(const std::string &name, const std::string &deflt="") const
Easy-to use interface to the ZYPP dependency resolver.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
IdType id() const
Expert backdoor.
bool parseTrialNode(const XmlNode &node, zypp::misc::testcase::TestcaseTrial::Node &testcaseNode)
ResolverFocus resolverFocus
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
std::vector< std::shared_ptr< Node > > children
reference value() const
Reference to the Tp object.
bool parseSetup(const XmlNode &setup, zypp::misc::testcase::TestcaseSetup &target, std::string *err)
bool ignorealreadyrecommended
std::optional< XmlNode > children() const
target::Modalias::ModaliasList modaliasList
bool parseTrial(const XmlNode &trial, zypp::misc::testcase::TestcaseTrial &target, std::string *)
AutoDispose()
Default Ctor using default constructed value and no dispose function.
std::vector< RepoData > repos
std::set< std::string > multiversionSpec
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
const set_type & removed() const
Return the set of removed items.
'Language[_Country]' codes.
void push(value_type val_r)
Push a value to the end off the Queue.
Pathname hardwareInfoFile