Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
normalize_prefix.cpp File Reference
#include <string>
#include <set>
#include <iostream>
#include <memory.h>
Include dependency graph for normalize_prefix.cpp:

Go to the source code of this file.

Typedefs

typedef unsigned char uint8
 

Functions

std::string normalize (const std::string &line)
 
int main ()
 

Typedef Documentation

◆ uint8

typedef unsigned char uint8

Definition at line 9 of file normalize_prefix.cpp.

Function Documentation

◆ main()

int main ( void )

Definition at line 38 of file normalize_prefix.cpp.

39{
40 std::string line;
41 while (std::getline(std::cin, line)) {
42 std::string normalizedLine = normalize(line);
43 std::cout << normalizedLine << '\n';//std::endl;
44 }
45}
std::string normalize(const std::string &line)
Here is the call graph for this function:

◆ normalize()

std::string normalize ( const std::string & line)

Definition at line 11 of file normalize_prefix.cpp.

12{
13 static const char tbl[][3] = { "66", "67", "F2", "F3" };
14 size_t tblNum = sizeof(tbl) / sizeof(tbl[0]);
15 typedef std::set<std::string> StringSet;
16 StringSet suf;
17
18 size_t pos = 0;
19 for (; pos < line.size(); pos += 2) {
20 bool found = false;
21 for (size_t i = 0; i < tblNum; i++) {
22 if (::memcmp(&line[pos], tbl[i], 2) == 0) {
23 found = true;
24 suf.insert(tbl[i]);
25 break;
26 }
27 }
28 if (!found) break;
29 }
30 std::string ret;
31 for (StringSet::const_iterator i = suf.begin(), e = suf.end(); i != e; ++i) {
32 ret += *i;
33 }
34 ret += &line[pos];
35 return ret;
36}
const struct Ptn tbl[]
CK_RV ret
Here is the caller graph for this function: