libzypp 17.38.6
solvableident.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#include "solvableident.h"
11#include <cstring>
12
13namespace zyppng::sat
14{
15 namespace
16 {
17 void _doSplit( IdString & _ident, ResKind & _kind, IdString & _name )
18 {
19 if ( ! _ident )
20 return;
21
22 ResKind explicitKind = ResKind::explicitBuiltin( _ident.c_str() );
23 // NOTE: kind package and srcpackage do not have namespaced ident!
24 if ( ! explicitKind )
25 {
26 _name = _ident;
27 // No kind defaults to package
28 if ( !_kind )
29 _kind = ResKind::package;
30 else if ( ! ( _kind == ResKind::package || _kind == ResKind::srcpackage ) )
31 _ident = IdString( zypp::str::form( "%s:%s", _kind.c_str(), _ident.c_str() ) );
32 }
33 else
34 {
35 // strip kind spec from name
36 _name = IdString( ::strchr( _ident.c_str(), ':' )+1 );
37 _kind = explicitKind;
38 if ( _kind == ResKind::package || _kind == ResKind::srcpackage )
39 _ident = _name;
40 }
41 return;
42 }
43 } // namespace
44
46 : _ident( ident_r )
47 { _doSplit( _ident, _kind, _name ); }
48
49 SplitIdent::SplitIdent( const char * ident_r )
50 : _ident( ident_r )
51 { _doSplit( _ident, _kind, _name ); }
52
53 SplitIdent::SplitIdent( const std::string & ident_r )
54 : _ident( ident_r )
55 { _doSplit( _ident, _kind, _name ); }
56
58 : _ident( name_r )
59 , _kind(std::move( kind_r ))
60 { _doSplit( _ident, _kind, _name ); }
61
62 SplitIdent::SplitIdent( ResKind kind_r, const zypp::C_Str & name_r )
63 : _ident( name_r )
64 , _kind(std::move( kind_r ))
65 { _doSplit( _ident, _kind, _name ); }
66
67} // namespace zyppng::sat
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Definition String.h:92
Access to the sat-pools string space.
Definition IdString.h:55
Resolvable kinds.
Definition ResKind.h:33
static const ResKind srcpackage
Definition ResKind.h:44
static ResKind explicitBuiltin(const char *str_r)
Return the builtin kind if str_r explicitly prefixed.
Definition ResKind.cc:46
static const ResKind package
Definition ResKind.h:40
Definition ansi.h:855
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
This file contains private API, this might break at any time between releases.
zypp::IdString IdString
Definition idstring.h:16