Skip to main content
gamedev.net
🔒 Locked

Question about structs

Started by kingpinzs 2 replies 750+ views
Original Post
kingpinzs
kingpinzs
GOAL: user loads file DONE file is scaned for main keywords DONE those keywords are all stored as indviduel varibles LINK LIST the key words are then placed in a drpo down box DONE when user selects a key word it will load the coresponding data NOTE: can slect indviduel iteams from drop down but cant load corsponding data Issues: 1)How do I link the data to the keyword? What May Work: I want to make a struct that is dynamic. What I mean by that is I want to be able to scan though a file and find key words and those key words I want the struct's "declared varible to be the key words that were found" example: struct sample{ int x; }; keyword1 sample; keyword2 sample; but I wont know what the key words are or really how many there are. My parser just scans my file to find them and loads them to a link list as strings. then I want to load the structs varibles dynamicaly with all the data that is supose to be link to that key word. NOTE: I may be using the wrong thing to hold all my data but I cant think of any other way to do this
Maega
Maega
Short answer: You can't do that.


Quote:

Issues:
1)How do I link the data to the keyword?


using C++? use std::map

Std::Map
kingpinzs
kingpinzs
This screen shot is my animation player. the animation type and animation settings are all loaded from a data file.



So the question is how to I select the imag type so it will bring up the right settings?
RabblePants
RabblePants
The best you can do it is create an internal object that manages 'keywords' and data, and then you poll for that data later on.

Ex:

MyData.AddType("Name", kStringType);MyData.AddType("Age", kIntType);MyData.AddType("Velocity", kFloatType);...MyData.SetData("Name", "Johnny Bravo");MyData.SetData("Age", 21);MyData.SetData("Velocity", 24.0f);...MyData.GetStringData("Name");MyData.GetIntData("Age");MyData.GetFloatData("Velocity");

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.