libept
Main Page
Namespaces
Classes
Files
File List
File Members
ept
token.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
#include <wibble/mixin.h>
3
#include <string>
4
5
#ifndef EPT_TOKEN_H
6
#define EPT_TOKEN_H
7
8
namespace
ept {
9
10
struct
Token
: wibble::mixin::Comparable< Token > {
11
std::string
_id
;
// formatted as package[_version]
12
std::string
id
()
const
{
return
_id
; }
13
14
Token
() :
_id
(
""
) {}
15
Token
( std::string s ) :
_id
( s ) {}
16
17
std::string
version
()
const
{
18
return
_id
.find(
'_'
) == std::string::npos ?
""
:
19
std::string(
_id
,
_id
.find(
'_'
) + 1,
_id
.size() );
20
}
21
22
std::string
package
()
const
{
23
return
std::string(
_id
, 0,
24
_id
.find(
'_'
) == std::string::npos ?
25
_id
.size() :
_id
.find(
'_'
) );
26
}
27
28
bool
isDesktop
()
const
{
29
return
std::string(
_id
, 0, 8 ) ==
"desktop:"
;
30
}
31
32
std::string
desktop
()
const
{
33
return
isDesktop
() ? std::string(
_id
, 8,
_id
.size() ) :
""
;
34
}
35
36
bool
hasVersion
()
const
{
37
return
version
() !=
""
;
38
}
39
40
bool
valid
()
const
{
41
return
_id
!=
""
;
42
}
43
44
bool
operator<=
(
const
Token
&o )
const
{
45
return
_id
<= o.
_id
;
46
}
47
};
48
49
}
50
51
inline
std::ostream &
operator<<
( std::ostream &o,
const
ept::Token
&t ) {
52
return
o << t.
id
();
53
}
54
55
#endif
Generated on Sat Nov 2 2013 08:30:07 for libept by
1.8.1.2