MCPcopy Create free account
hub / github.com/apache/trafficserver / main

Function main

lib/yamlcpp/util/read.cpp:43–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43int main(int argc, char** argv) {
44 int N = 1;
45 bool cache = false;
46 std::string filename;
47 for (int i = 1; i < argc; i++) {
48 std::string arg = argv[i];
49 if (arg == "-n") {
50 i++;
51 if (i >= argc) {
52 usage();
53 return -1;
54 }
55 N = std::atoi(argv[i]);
56 if (N <= 0) {
57 usage();
58 return -1;
59 }
60 } else if (arg == "-c" || arg == "--cache") {
61 cache = true;
62 } else {
63 filename = argv[i];
64 if (i + 1 != argc) {
65 usage();
66 return -1;
67 }
68 }
69 }
70
71 if (N > 1 && !cache && filename.empty()) {
72 usage();
73 return -1;
74 }
75
76 if (cache) {
77 std::string input;
78 if (!filename.empty()) {
79 std::ifstream in(filename);
80 input = read_stream(in);
81 } else {
82 input = read_stream(std::cin);
83 }
84 std::istringstream in(input);
85 for (int i = 0; i < N; i++) {
86 in.seekg(std::ios_base::beg);
87 run(in);
88 }
89 } else {
90 if (!filename.empty()) {
91 std::ifstream in(filename);
92 for (int i = 0; i < N; i++) {
93 in.seekg(std::ios_base::beg);
94 run(in);
95 }
96 } else {
97 for (int i = 0; i < N; i++) {
98 run(std::cin);
99 }
100 }

Callers

nothing calls this directly

Calls 4

read_streamFunction · 0.85
usageFunction · 0.70
runFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected