Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (C) 2010 by Thomas Moulard, CNRS. | ||
2 | // | ||
3 | |||
4 | // Redistribution and use in source and binary forms, with or without | ||
5 | // modification, are permitted provided that the following conditions are | ||
6 | // met: | ||
7 | // | ||
8 | // 1. Redistributions of source code must retain the above copyright | ||
9 | // notice, this list of conditions and the following disclaimer. | ||
10 | // | ||
11 | // 2. Redistributions in binary form must reproduce the above copyright | ||
12 | // notice, this list of conditions and the following disclaimer in the | ||
13 | // documentation and/or other materials provided with the distribution. | ||
14 | // | ||
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
18 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
19 | // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
20 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
21 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
22 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
23 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
25 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
26 | // DAMAGE. | ||
27 | |||
28 | #include "hpp/util/version.hh" | ||
29 | |||
30 | #include <assert.h> | ||
31 | |||
32 | #include <hpp/util/string.hh> | ||
33 | #include <string> | ||
34 | #include <vector> | ||
35 | |||
36 | #include "config.h" | ||
37 | |||
38 | namespace hpp { | ||
39 | namespace util { | ||
40 | const char* version = PACKAGE_VERSION; | ||
41 | |||
42 | 1 | int checkVersion(const char* header_version) { | |
43 | std::vector<std::string> headerVersion = string_split( | ||
44 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | header_version, header_version + std::strlen(header_version), '.'); |
45 | std::vector<std::string> libraryVersion = | ||
46 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | string_split(version, version + std::strlen(version), '.'); |
47 | |||
48 | 1 | long unsigned s = std::max(headerVersion.size(), libraryVersion.size()); | |
49 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | headerVersion.resize(s); |
50 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | libraryVersion.resize(s); |
51 | |||
52 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | assert(headerVersion.size() == libraryVersion.size()); |
53 | |||
54 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | for (long unsigned i = 0; i < s; ++i) |
55 |
2/4✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | if (headerVersion != libraryVersion) |
56 | ✗ | return (headerVersion > libraryVersion) ? -1 : 1; | |
57 | 1 | return 0; | |
58 | 1 | } | |
59 | } // end of namespace util. | ||
60 | } // end of namespace hpp. | ||
61 |