#ifndef COMPANYMEMORYUTILS_H #define COMPANYMEMORYUTILS_H #include "Company.h" typedef unsigned char byte; class CompanyMemoryUtils { friend std::vector readCompaniesFromMemory(byte* memory, int Companies); }; std::vector readCompaniesFromMemory(byte* memory, int Companies) { std::vector output; while (Companies--) { int id = *memory; std::string name; std::vector < std::pair> symbs; memory++; while (*memory != '\0') { name += *memory; memory++; } memory++; int times = *memory, i = 0; while (times--) { memory++; symbs.push_back({ *memory, *(++memory) }); symbs.at(i++).second = *memory; } memory++; output.push_back(Company(id, name, symbs)); } return output; } #endif