~ppsspp/ppsspp/ppsspp-1.1.1

« back to all changes in this revision

Viewing changes to ext/native/util/text/parsers.h

  • Committer: Sérgio Benjamim
  • Date: 2015-10-17 01:37:55 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20151017013755-avrlz2pt37kwt43x
PPSSPP 1.1.1 source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma once
 
2
 
 
3
#include <string>
 
4
 
 
5
#include "base/basictypes.h"
 
6
 
 
7
#undef major
 
8
#undef minor
 
9
 
 
10
// Parses version strings of the format "Major.Minor.Sub" and lets you interact with them conveniently.
 
11
struct Version {
 
12
        Version() : major(0), minor(0), sub(0) {}
 
13
        Version(const std::string &str) {
 
14
                if (!ParseVersionString(str)) {
 
15
                        major = -1;
 
16
                        minor = -1;
 
17
                        sub = -1;
 
18
                }
 
19
        }
 
20
 
 
21
        int major;
 
22
        int minor;
 
23
        int sub;
 
24
 
 
25
        bool IsValid() const {
 
26
                return sub >= 0 && minor >= 0 && major >= 0;
 
27
        }
 
28
 
 
29
        bool operator == (const Version &other) const {
 
30
                return major == other.major && minor == other.minor && sub == other.sub;
 
31
        }
 
32
        bool operator != (const Version &other) const {
 
33
                return !(*this == other);
 
34
        }
 
35
 
 
36
        bool operator <(const Version &other) const {
 
37
                if (major < other.major) return true;
 
38
                if (major > other.major) return false;
 
39
                if (minor < other.minor) return true;
 
40
                if (minor > other.minor) return false;
 
41
                if (sub < other.sub) return true;
 
42
                if (sub > other.sub) return false;
 
43
                return false;
 
44
        }
 
45
 
 
46
        bool operator >=(const Version &other) const {
 
47
                return !(*this < other);
 
48
        }
 
49
 
 
50
        std::string ToString() const;
 
51
private:
 
52
        bool ParseVersionString(std::string str);
 
53
};
 
54
 
 
55
bool ParseMacAddress(std::string str, uint8_t macAddr[6]);
 
 
b'\\ No newline at end of file'