| Rii (24) | |||||||
|
Hello there ^^ I was wondering how I could read a text file with multiple data structures(not sure if it's called that way) into a matrix(typedef std::map<std::string, std::vector<std::string>> matrix) and header(typedef std::map<std::string, short> header) without creating additional ones. Google didn't work any magic for me today. (Wasn't sure if I should post in beginners or here) Part of the text file (they're really big):
I am able to read
I was wondering if it's possible to put
I minimized the amount of code to demonstrate what I currently use
I can easily access the data I want with data["Cat"][index["TEXT"]]; to get "Chen". So I'm wondering if it's possible with the same matrix and header to do stuff like data["Cat"][index["LABEL"]] = "Affection" and if it's safe to use an iterator when there are two of the same START names.~ Rii | |||||||
|
|
|||||||
| rollie (304) | |
| Is 'ID' is a species type (if youkai can be considered a species...same idea though), and 'TEXT' is a name of a specific entity? So there might be multiple rows with ID = cat, each at a different location, with a different name? For the second table, I assume that represents the relationship between 2 species; if it says CAT YOUKAI AFFECTION, does that also mean YOUKAI CAT AFFECTION? What does 'CREATENEW' mean? | |
|
|
|
| Rii (24) | ||
|
ID is a name that I read from another file which can't be edited, this value will never be the same with something else (there can't be two Youkai, this value is used to search, it can also be 445 instead of Cat, or anything else random) TEXT is the name that will be displayed instead of ID. (Self created, There can be two Chen this way for example) X and Y are coordinates START is the first ID that will be used in a linkage between two IDs. (This is ordered) END is the second ID that's used in the linkage. LABEL is the sort of linkage the two have. (The link Cat has with Fox is Affection) CREATENEW is something I put to 1 to draw a START that doesn't exist.
| ||
|
|
||
| rollie (304) | |||
Maybe a structure like this:
| |||
|
|
|||
| Rii (24) | ||
|
Thank you for your reply, I like this struct, I'll use it, thank you! But I actually wanted to know what method I could use to read the file, I couldn't find anything regarding the file I have, I only know how to read the
The new data starts after an empty line | ||
|
Last edited on
|
||
| rollie (304) | |||
Oh...well that's easier :P
| |||
|
Last edited on
|
|||
| Rii (24) | |
|
Thank you so much! Perfect! Sorry for the confusion at first, I thought it might be needed to explain the data, but I have something better now :D Thank you once again! *Sorry for barging in with a somewhat newbie question, I didn't get any replies in the beginner forums so I thought it was something advanced >.<"* | |
|
|
|