MCPcopy Create free account
hub / github.com/axmolengine/axmol / readFile

Method readFile

core/network/HttpCookie.cpp:47–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45namespace network
46{
47void HttpCookie::readFile()
48{
49 enum
50 {
51 DOMAIN_INDEX = 0,
52 TAILMATCH_INDEX,
53 PATH_INDEX,
54 SECURE_INDEX,
55 EXPIRES_INDEX,
56 NAME_INDEX,
57 VALUE_INDEX,
58 };
59
60 using namespace std::literals::string_view_literals;
61
62 std::string inString = FileUtils::getInstance()->getStringFromFile(_cookieFileName);
63 if (!inString.empty())
64 {
65 axstd::split_cb(&inString.front(), inString.length(), '\n', [this](char* s, char* e) {
66 if (*s == '#') // skip comment
67 return;
68 int count = 0;
69 CookieInfo cookieInfo;
70 using namespace cxx17;
71 axstd::split_cb(s, e - s, '\t', [&, this](char* ss, char* ee) {
72 auto ch = *ee; // store
73 *ee = '\0';
74 switch (count)
75 {
76 case DOMAIN_INDEX:
77 cookieInfo.domain.assign(ss, ee - ss);
78 break;
79 case PATH_INDEX:
80 cookieInfo.path.assign(ss, ee - ss);
81 break;
82 case SECURE_INDEX:
83 cookieInfo.secure = cxx17::string_view{ss, (size_t)(ee - ss)} == "TRUE"_sv;
84 break;
85 case EXPIRES_INDEX:
86 cookieInfo.expires = static_cast<time_t>(strtoll(ss, nullptr, 10));
87 break;
88 case NAME_INDEX:
89 cookieInfo.name.assign(ss, ee - ss);
90 break;
91 case VALUE_INDEX:
92 cookieInfo.value.assign(ss, ee - ss);
93 break;
94 }
95 *ee = ch; // restore
96 ++count;
97 });
98 if (count >= 7)
99 _cookies.push_back(std::move(cookieInfo));
100 });
101 }
102}
103
104const std::vector<CookieInfo>* HttpCookie::getCookies() const

Callers 2

enableCookiesMethod · 0.80
processResponseMethod · 0.80

Calls 8

getInstanceFunction · 0.85
split_cbFunction · 0.85
getStringFromFileMethod · 0.80
emptyMethod · 0.45
frontMethod · 0.45
lengthMethod · 0.45
assignMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected