Lines Matching refs:fileContent
201 std::string fileContent;
202 if (!ReadFile(filePath, fileContent)) {
211 ParserFileConfig(fileContent, iface, cfg);
238 std::string fileContent;
239 GenCfgContent(iface, cfg, fileContent);
242 return WriteFile(filePath, fileContent);
435 bool EthernetConfiguration::ReadFile(const std::string &filePath, std::string &fileContent)
454 fileContent = buffer.str();
459 bool EthernetConfiguration::WriteFile(const std::string &filePath, const std::string &fileContent)
467 file << fileContent.c_str();
473 void EthernetConfiguration::ParserFileConfig(const std::string &fileContent, std::string &iface,
476 ParseDevice(fileContent, iface);
477 ParseBootProto(fileContent, cfg);
478 ParseStaticConfig(fileContent, cfg);
479 ParserFileHttpProxy(fileContent, cfg);
482 void EthernetConfiguration::ParseDevice(const std::string &fileContent, std::string &iface)
484 std::string::size_type pos = fileContent.find(KEY_DEVICE);
489 const auto &device = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
493 void EthernetConfiguration::ParseBootProto(const std::string &fileContent, sptr<InterfaceConfiguration> cfg)
495 std::string::size_type pos = fileContent.find(KEY_BOOTPROTO);
500 const auto &bootProto = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
512 void EthernetConfiguration::ParseStaticConfig(const std::string &fileContent, sptr<InterfaceConfiguration> cfg)
518 auto pos = fileContent.find(KEY_IPADDR);
521 ipAddresses = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
524 pos = fileContent.find(KEY_NETMASK);
527 netMasks = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
530 pos = fileContent.find(KEY_GATEWAY);
533 gateways = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
536 pos = fileContent.find(KEY_ROUTE);
539 routes = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
542 pos = fileContent.find(KEY_ROUTE_NETMASK);
545 routeMasks = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
548 pos = fileContent.find(KEY_DNS);
551 dnsServers = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
562 void EthernetConfiguration::ParserFileHttpProxy(const std::string &fileContent, const sptr<InterfaceConfiguration> &cfg)
564 std::string::size_type pos = fileContent.find(KEY_PROXY_HOST);
567 cfg->httpProxy_.SetHost(fileContent.substr(pos, fileContent.find(WRAP, pos) - pos));
570 pos = fileContent.find(KEY_PROXY_PORT);
573 uint32_t port = CommonUtils::StrToUint(fileContent.substr(pos, fileContent.find(WRAP, pos) - pos));
577 pos = fileContent.find(KEY_PROXY_EXCLUSIONS);
580 auto exclusions = fileContent.substr(pos, fileContent.find(WRAP, pos) - pos);
638 std::string &fileContent)
644 std::string().swap(fileContent);
645 fileContent = fileContent + KEY_DEVICE + iface + WRAP;
647 fileContent = fileContent + KEY_BOOTPROTO + mode + WRAP;
662 fileContent = fileContent + KEY_IPADDR + ipAddresses + WRAP;
663 fileContent = fileContent + KEY_NETMASK + netMasks + WRAP;
664 fileContent = fileContent + KEY_GATEWAY + gateways + WRAP;
665 fileContent = fileContent + KEY_ROUTE + routes + WRAP;
666 fileContent = fileContent + KEY_ROUTE_NETMASK + routeMasks + WRAP;
667 fileContent = fileContent + KEY_DNS + dnsServers + WRAP;
669 GenHttpProxyContent(cfg, fileContent);
672 void EthernetConfiguration::GenHttpProxyContent(const sptr<InterfaceConfiguration> &cfg, std::string &fileContent)
681 fileContent = fileContent + KEY_PROXY_HOST + cfg->httpProxy_.GetHost() + WRAP;
682 fileContent = fileContent + KEY_PROXY_PORT + std::to_string(cfg->httpProxy_.GetPort()) + WRAP;
683 fileContent = fileContent + KEY_PROXY_EXCLUSIONS + exclusions + WRAP;