Web Wispers 1.2.2 C++ Unit Test Coverage |
|
|
|
|
Branch data Line data Source code
1 : : /*
2 : : * Copyright 2010 Savarese Software Research Corporation
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 : : * https://www.savarese.com/software/ApacheLicense-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 : : /**
18 : : * @file
19 : : * This header defines the UUIDGenerator class.
20 : : */
21 : :
22 : : #ifndef __SSRC_WSPR_UTILITY_UUID_GENERATOR_H
23 : : #define __SSRC_WSPR_UTILITY_UUID_GENERATOR_H
24 : :
25 : : #include <ssrc/wispers/types.h>
26 : :
27 : : #include <boost/uuid/uuid.hpp>
28 : : #include <boost/uuid/uuid_generators.hpp>
29 : :
30 : : __BEGIN_NS_SSRC_WSPR_UTILITY
31 : :
32 : : uuid_key_type uuid_to_uuid_key(const boost::uuids::uuid & uuid);
33 : :
34 : : inline uuid_key_type str_to_uuid_key(const std::string & str)
35 : : // Thrown by string_generator for invalid uuid strings
36 : : SSRC_DECL_THROW(std::runtime_error)
37 : : {
38 : : boost::uuids::string_generator uuid_str_gen;
39 : : return uuid_to_uuid_key(uuid_str_gen(str));
40 : : }
41 : :
42 : 1 : class UUIDGenerator {
43 : :
44 : : mutable boost::uuids::random_generator _gen_uuid;
45 : :
46 : : public:
47 : :
48 : 1 : UUIDGenerator() { }
49 : :
50 : 100 : boost::uuids::uuid gen_uuid() const {
51 : 100 : return _gen_uuid();
52 : : }
53 : :
54 : : uuid_key_type gen_uuid_key() const {
55 : : return uuid_to_uuid_key(gen_uuid());
56 : : }
57 : : };
58 : :
59 : : __END_NS_SSRC_WSPR_UTILITY
60 : :
61 : : #endif
|
Copyright © 2017 Savarese Software Research Corporation. All rights reserved