Hello! I have my own custom binary model format and I am trying to read it using ifstream, but ran into a problem. I have a class called NXNode which contains the name of each scene node. The problem is that the name's size varies. How would I read the string correctly when I don't know it's size? I know BinaryReader.ReadString() does it without me specifying the size, so it must be possible with C++ too right? Thanks!
[EDIT: Here's some code if it helps]
NXNode::NXNode(ifstream* reader, NXNode* parent) : NXNode()
{
if (parent != NULL)
Parent = parent;
reader->read((char*) &Name, sizeof(string));
reader->read((char*)&HasChildren, sizeof(bool));
reader->read((char*)&MeshCount, sizeof(short));
reader->read((char*)&ChildCount, sizeof(short));
float nums[16];
for (int i = 0; i < 16; i++)
{
reader->read((char*) &nums[i], sizeof(float));
}
if (HasChildren)
{
Children = new NXNode[ChildCount];
for (int i = 0; i < ChildCount; i++)
{
Children[i] = NXNode(reader, this);
}
}
}