MCPcopy Create free account
hub / github.com/Norbyte/ositools / FromString

Method FromString

OsiInterface/DataLibraries.cpp:41–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 }
40
41 void Pattern::FromString(std::string const & s)
42 {
43 if (s.size() % 3) Fail("Invalid pattern length");
44 auto len = s.size() / 3;
45 if (!len) Fail("Zero-length patterns not allowed");
46
47 pattern_.reserve(len);
48
49 char const * c = s.data();
50 for (auto i = 0; i < len; i++) {
51 PatternByte b;
52 if (c[2] != ' ') Fail("Bytes must be separated by space");
53 if (c[0] == 'X' && c[1] == 'X') {
54 b.pattern = 0;
55 b.mask = 0;
56 }
57 else {
58 b.pattern = HexByteToByte(c[0], c[1]);
59 b.mask = 0xff;
60 }
61
62 pattern_.push_back(b);
63 c += 3;
64 }
65
66 if (pattern_[0].mask != 0xff) Fail("First byte of pattern must be an exact match");
67 }
68
69 void Pattern::FromRaw(const char * s)
70 {

Calls 2

HexByteToByteFunction · 0.85
FailFunction · 0.70

Tested by

no test coverage detected