File: ChangeListID.cpp

package info (click to toggle)
pbseqlib 5.3.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,020 kB
  • sloc: cpp: 77,246; python: 331; sh: 103; makefile: 42
file content (65 lines) | stat: -rw-r--r-- 1,618 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <pbdata/ChangeListID.hpp>

#include <sstream>

ChangeListID::ChangeListID() {}
ChangeListID::ChangeListID(std::string &idStringP) { StoreString(idStringP); }

void ChangeListID::StoreString(std::string &idStringP)
{
    idString = idStringP;
    std::stringstream ss(idString);
    std::string part;
    intVer.clear();
    while (std::getline(ss, part, '.')) {
        intVer.push_back(std::atoi(part.c_str()));
    }
}

int ChangeListID::LessThan(ChangeListID &rhs, int depth)
{
    if (depth == 0) {
        depth = std::min(intVer.size(), rhs.intVer.size());
    }
    int i;
    for (i = 0; i < depth; i++) {
        if (intVer[i] != rhs.intVer[i]) {
            return intVer[i] < rhs.intVer[i];
        }
    }
    return 0;  // making it here they are equal
}

QVScale ChangeListID::DetermineQVScaleFromChangeListID()
{
    ChangeListID phredCL;
    phredCL.intVer.resize(3);
    phredCL.intVer[0] = 1;
    phredCL.intVer[1] = 2;
    phredCL.intVer[2] = 2;
    if (LessThan(phredCL)) {
        return POverOneMinusP;
    } else {
        return PHRED;
    }
}

// utility method
void AppendPerforceChangelist(std::string perforceVersionString, std::string &version)
{
    if (perforceVersionString.size() > 12) {
        version.insert(version.size(), ".");
        version.insert(version.size(), perforceVersionString, 9, perforceVersionString.size() - 11);
    }
}

std::string ChangeListID::GetVersion()
{
    std::stringstream ss;
    if (intVer.size() == 1) {
        ss << intVer[0];
    } else if (intVer.size() >= 2) {
        ss << intVer[0] << "." << intVer[1];
    }
    return ss.str();
}