MCPcopy Create free account
hub / github.com/HailToDodongo/pyrite64 / writeAs

Method writeAs

src/utils/binaryFile.h:109–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107 }
108
109 void writeAs(const std::string &str, DataType type) {
110 switch(type) {
111 case f32: write<float>(std::stof(str)); break;
112 case u32: write<uint32_t>(std::stoul(str)); break;
113 case s32: write<int32_t>(std::stol(str)); break;
114 case u16: write<uint16_t>(std::stoul(str)); break;
115 case s16: write<int16_t>(std::stol(str)); break;
116 case u8: write<uint8_t>(std::stoul(str)); break;
117 case s8: write<int8_t>(std::stol(str)); break;
118 case OBJECT_REF: write<uint32_t>(std::stoul(str)); break;
119 case PREFAB: write<uint32_t>(std::stoul(str)); break;
120 case string:
121 for(char c : str)write<uint8_t>(c);
122 write<uint8_t>(0);
123 break;
124 default:
125 throw std::runtime_error("unsupported data type");
126 }
127 }
128
129 void writeMemFile(const BinaryFile& memFile) {
130 writeRaw(memFile.data.data(), memFile.dataSize);

Callers 1

buildFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected