MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / getTempfileControls

Function getTempfileControls

samples/common/sampleOptions.cpp:798–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

796}
797
798void getTempfileControls(Arguments& arguments, char const* argument, TempfileControlFlags& tempfileControls)
799{
800 std::string list;
801 if (!getAndDelOption(arguments, argument, list))
802 {
803 return;
804 }
805
806 std::vector<std::string> controlList{splitToStringVec(list, ',')};
807 for (auto const& s : controlList)
808 {
809 auto controlAllowPair = splitNameAndValue<std::string>(s);
810 bool allowed{false};
811 int32_t offset{-1};
812
813 if (controlAllowPair.second.compare("allow") == 0)
814 {
815 allowed = true;
816 }
817 else if (controlAllowPair.second.compare("deny") != 0)
818 {
819 throw std::invalid_argument("--tempfileControls value should be `deny` or `allow`");
820 }
821
822 if (controlAllowPair.first.compare("in_memory") == 0)
823 {
824 offset = static_cast<int32_t>(TempfileControlFlag::kALLOW_IN_MEMORY_FILES);
825 }
826 else if (controlAllowPair.first.compare("temporary") == 0)
827 {
828 offset = static_cast<int32_t>(TempfileControlFlag::kALLOW_TEMPORARY_FILES);
829 }
830 else
831 {
832 throw std::invalid_argument(std::string{"Unknown --tempfileControls key "} + controlAllowPair.first);
833 }
834
835 if (allowed)
836 {
837 tempfileControls |= (1U << offset);
838 }
839 else
840 {
841 tempfileControls &= ~(1U << offset);
842 }
843 }
844}
845
846void BuildOptions::parse(Arguments& arguments)
847{

Callers 1

parseMethod · 0.85

Calls 2

getAndDelOptionFunction · 0.85
splitToStringVecFunction · 0.85

Tested by

no test coverage detected