[2.0.3]-SDL_RWread() - Read Only One Line? |
JeZ-l-Lee
|
Sorry, I forgot the file:
(you can't see it, but each line is terminated by correct end of line char(s) based on OS platform)
|
|||||||||||||
|
[2.0.3]-SDL_RWread() - Read Only One Line? |
Jonny D
|
If you aren't comfortable writing and debugging the code to construct and parse your own format, then you should definitely use an existing one with a higher-level interface. When I need a simple text formatted file, I use tinyxml2 personally, but there are lots of good options out there.
Jonny D On Thu, May 7, 2015 at 10:44 AM, JeZ-l-Lee wrote:
|
|||||||||||||
|
Re: [2.0.3]-SDL_RWread() - Read Only One Line? |
JeZ-l-Lee
|
Thanks for the info... I looked at tinyxml2, is it cross-platform (Windows/Linux/Mac OS X) ? I was hoping to get it working with just SDL2 though, which I think would be best. I got the saving data working perfectly now, just need to fix loading data... |
|||||||||||||
|
[2.0.3]-SDL_RWread() - Read Only One Line? |
Jonny D
|
Yes, tinyxml2 is cross-platform. It also has functions for working in-memory, so you can still load using SDL_RWops, but parse it as XML (important for Android assets).
While it is nice to have only a dependency on SDL2, you're going to come across problems that are more efficiently solved by using the work of others. It's totally up to you how you solve these problems, but I recommend keeping your eyes open to options that will help get your projects to completion with less time, work, and bugs. Jonny D On Thu, May 7, 2015 at 12:11 PM, JeZ-l-Lee wrote:
|
|||||||||||||
|
MrTAToad
|
My Triority system has a function that allows reading of one line of text, dealing with the three line terminators properly (hopefully).
The system mentioned uses std::fstream, but I have recently converted it to RWops, so I'll post the code for that later |
|||||||||||
|
MrTAToad
|
Here it is :
|
|||||||||||||
|
JeZ-l-Lee
|
I appreciate that, I do... I almost got this working though. I found this: http://wiki.libsdl.org/SDL_RWseek and I believe it can solve my issue. Problem is how do I use above function to move to the next line? Thanks! |
|||||||||||||
|
MrTAToad
|
Unless each line is a specific length and ends in a specific way, you wouldn't be able to use binary mode without using something like my routine to get to the end of a line.
You could use RWops in text mode, and create a text array of a specific size that you (hope) the line wont exceed, and then use SDL_RWread to read up to that size. However, the documentation doesn't state what would happen if you try to read this amount but the line is shorter - I dont know whether it will x amount of characters or whether it will read up to the line terminator. |
|||||||||||
|
JeZ-l-Lee
|
Hi,
It took some deep thought, but we got everything working now. Thanks to all that helped! |
|||||||||||
|