Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JUUID Struct Reference

Simple wrapper for UUID. More...

#include <JUUID.hh>

Inheritance diagram for JLANG::JUUID:
JLANG::JComparable< JUUID >

Public Member Functions

 JUUID ()
 Default constructor.
 
 JUUID (const uuid_t &object)
 Copy constructor.
 
 JUUID (const JUUID &object)
 Copy constructor.
 
const JUUIDoperator() ()
 Randomizde this UUID.
 
bool is_valid () const
 Check validity.
 
void clear ()
 Clear UUID.
 
bool less (const JUUID &object) const
 Less than method.
 

Static Public Member Functions

static const JUUIDrndm ()
 Generate random UUID.
 
static JUUID valueOf (const std::string &buffer)
 Extract UUID.
 

Public Attributes

uuid_t uuid
 

Static Public Attributes

static const int BUFFER_SIZE = 36
 number of characters for I/O of uuid_t without trailing '\0', see e.g. man uuid_parse
 

Friends

std::istream & operator>> (std::istream &in, JUUID &object)
 Read object identifier from input.
 
std::ostream & operator<< (std::ostream &out, const JUUID &object)
 Write object identifier to output.
 

Detailed Description

Simple wrapper for UUID.

Definition at line 22 of file JUUID.hh.

Constructor & Destructor Documentation

◆ JUUID() [1/3]

JLANG::JUUID::JUUID ( )
inline

Default constructor.

Definition at line 32 of file JUUID.hh.

33 {
34 clear();
35 }
void clear()
Clear UUID.
Definition JUUID.hh:100

◆ JUUID() [2/3]

JLANG::JUUID::JUUID ( const uuid_t & object)
inline

Copy constructor.

Parameters
objectUUID

Definition at line 43 of file JUUID.hh.

44 {
45 uuid_copy(this->uuid, object);
46 }
uuid_t uuid
Definition JUUID.hh:172

◆ JUUID() [3/3]

JLANG::JUUID::JUUID ( const JUUID & object)
inline

Copy constructor.

Parameters
objectUUID

Definition at line 54 of file JUUID.hh.

55 {
56 uuid_copy(this->uuid, object.uuid);
57 }

Member Function Documentation

◆ operator()()

const JUUID & JLANG::JUUID::operator() ( )
inline

Randomizde this UUID.

Returns
this UUID

Definition at line 65 of file JUUID.hh.

66 {
67 uuid_generate_random(this->uuid);
68
69 return *this;
70 }

◆ rndm()

static const JUUID & JLANG::JUUID::rndm ( )
inlinestatic

Generate random UUID.

Returns
UUID

Definition at line 78 of file JUUID.hh.

79 {
80 static JUUID id;
81
82 return id();
83 }
JUUID()
Default constructor.
Definition JUUID.hh:32

◆ is_valid()

bool JLANG::JUUID::is_valid ( ) const
inline

Check validity.

Returns
true if valid; else false

Definition at line 91 of file JUUID.hh.

92 {
93 return uuid_is_null(this->uuid) == 0;
94 }

◆ clear()

void JLANG::JUUID::clear ( )
inline

Clear UUID.

Definition at line 100 of file JUUID.hh.

101 {
102 return uuid_clear(this->uuid);
103 }

◆ less()

bool JLANG::JUUID::less ( const JUUID & object) const
inline

Less than method.

Parameters
objectUUID
Returns
true if this UUID less than given UUID; else false

Definition at line 112 of file JUUID.hh.

113 {
114 return uuid_compare(this->uuid, object.uuid) < 0;
115 }

◆ valueOf()

static JUUID JLANG::JUUID::valueOf ( const std::string & buffer)
inlinestatic

Extract UUID.

Parameters
bufferUUID
Returns
UUID

Definition at line 124 of file JUUID.hh.

125 {
126 JUUID object;
127
128 uuid_parse(buffer.c_str(), object.uuid);
129
130 return object;
131 }

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JUUID & object )
friend

Read object identifier from input.

Parameters
ininput stream
objectobject identifier
Returns
input stream

Definition at line 141 of file JUUID.hh.

142 {
143 char buffer[BUFFER_SIZE + 1];
144
145 if (in.read(buffer, BUFFER_SIZE)) {
146
147 buffer[BUFFER_SIZE] = '\0';
148
149 uuid_parse(buffer, object.uuid);
150 }
151
152 return in;
153 }
static const int BUFFER_SIZE
number of characters for I/O of uuid_t without trailing '\0', see e.g. man uuid_parse
Definition JUUID.hh:26

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JUUID & object )
friend

Write object identifier to output.

Parameters
outoutput stream
objectobject identifier
Returns
output stream

Definition at line 163 of file JUUID.hh.

164 {
165 char buffer[BUFFER_SIZE + 1];
166
167 uuid_unparse_lower(object.uuid, buffer);
168
169 return out.write(buffer, BUFFER_SIZE);
170 }

Member Data Documentation

◆ BUFFER_SIZE

const int JLANG::JUUID::BUFFER_SIZE = 36
static

number of characters for I/O of uuid_t without trailing '\0', see e.g. man uuid_parse

Definition at line 26 of file JUUID.hh.

◆ uuid

uuid_t JLANG::JUUID::uuid

Definition at line 172 of file JUUID.hh.


The documentation for this struct was generated from the following file: