blob: eba4d3375e26e101cfe3ab5300161d0cf62163b6 (
plain)
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
|
#pragma once
#include "types.hpp"
#include "Version.hpp"
#include "Result.hpp"
#include "StringView.hpp"
#include <string>
namespace sibs
{
Result<PackageVersion> parsePackageVersion(const StringView &versionStr, int *size);
enum class VersionToken
{
NONE,
END_OF_FILE,
INVALID,
OPERATION,
AND,
VERSION_NUMBER
};
struct VersionTokenizer
{
VersionTokenizer();
VersionTokenizer(const char *start, const usize size);
VersionTokenizer(const VersionTokenizer &other);
VersionToken next();
const char *start;
const char *code;
usize size;
usize index;
PackageVersion version;
VersionOperation operation;
StringView identifier;
std::string errMsg;
};
struct VersionParser
{
Result<PackageVersionRange> parse(const char *code, const usize size);
VersionTokenizer tokenizer;
PackageVersionRange versionRange;
private:
VersionToken parseStart();
VersionToken parseEnd();
};
}
|