Gazebo Common

API Reference

4.7.0
gz/common/Uuid.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_COMMON_UUID_HH_INCLUDED_
18 #define IGNITION_COMMON_UUID_HH_INCLUDED_
19 
20 #include <iostream>
21 #include <string>
22 
23 #include <gz/common/config.hh>
24 #include <gz/common/Export.hh>
25 
26 #ifdef _WIN32
27  #include <Rpc.h>
28  #pragma comment(lib, "Rpcrt4.lib")
29  using portable_uuid_t = UUID;
30 // else unix
31 #else
32  #include <uuid/uuid.h>
33  using portable_uuid_t = uuid_t;
34 #endif
35 
36 namespace ignition
37 {
38  namespace common
39  {
41  class IGNITION_COMMON_VISIBLE Uuid
42  {
44  public: Uuid();
45 
47  public: virtual ~Uuid();
48 
51  public: std::string String() const;
52 
56  public: friend std::ostream &operator<<(std::ostream &_out,
57  const ignition::common::Uuid &_uuid)
58  {
59  _out << _uuid.String();
60  return _out;
61  }
62 
69  private: static const int UuidStrLen = 37;
70 
72  private: portable_uuid_t data;
73  };
74  }
75 }
76 #endif
Forward declarations for the common classes.
STL class.
std::string String() const
Return the string representation of the Uuid.
friend std::ostream & operator<<(std::ostream &_out, const ignition::common::Uuid &_uuid)
Stream insertion operator.
Definition: gz/common/Uuid.hh:56
STL class.
virtual ~Uuid()
Destructor.
A portable class for representing a Universally Unique Identifier.
Definition: gz/common/Uuid.hh:41
uuid_t portable_uuid_t
Definition: gz/common/Uuid.hh:33