• entries
    707
  • comments
    1173
  • views
    432944

Quick update

Sign in to follow this  
Programmer16

74 views

Got some work done today, but most of my time was wasted playing through Oblivion (had to beat the main quest line so I could move onto the Shivering Isles and then I had to beat that lol.) Anyway, I'm pretty much just getting started. I have about 90 classes to go (at the moment; more than likely I'll add/remove some along the way), but almost half of them are GUI classes.

I'm spending a lot more time making sure things are consistent though. For example, the following would work for any of my math classes:

template void Display(const ValueType &Value)
{
MessageBox(0, Value.ToString().c_str(), "Displaying value...", 0);
}

template ValueType Load(std::ifstream &Stream)
{
char Buffer[256];
Stream.getline(Buffer, 255);
return ValueType::FromString(Buffer);
}

template ValueType Load(TiXmlElement *Element)
{
return ValueType::FromXmlElement(Element);
}


I wouldn't actually use any of them (other than for testing or something), but they would work for all of my classes. Hell, they'd ever work for some of my other classes.


I know I keep changing my plans, but I need to start thinking more about my future and less about practice. I'm going to do Chompy, Blocks Gone Wild, and Spelunker to test the engine, but then I'm going to focus on something else. I still plan on finishing Invasion, it's just going to take a little longer than I want it to.

I need to go to sleep now. kthxbai
Sign in to follow this  


2 Comments


Recommended Comments

Wow, 90 classes? Seems like a bunch - would be interested in seeing the list :). Quick question on the code you posted:


template <typename ValueType> ValueType Load(std::ifstream &Stream)
{
char Buffer[256];
Stream.getline(Buffer, 255);
return ValueType::FromString(Buffer);
}



Seems like that should be


template <typename ValueType> ValueType Load(std::ifstream &Stream)
{
return ValueType::FromString(Stream);
}



I.e. why the 255 character limit instead of just having the underlying ValueType::FromString method read in the data it needs from the stream?

Share this comment


Link to comment
Hm, I could probably post a list of all the classes I have planned. We'll see; I'm still ironing it out atm.

And it's done that way because the method is "FromString()" not "FromStream()" ~_^. As I said though, it's just an example. The method doesn't care how long the string is, it just needs to be in the format "Type(values)". For example, Point::FromString() requires "Point(x,y)", Rectangle::FromString() requires "Rectangle(left,top,right,bottom)" and Color::FromString() requires one of the following: "Argb(a,r,g,b)", "Rgb(r,g,b)", or "Named(color)".

Thanks!

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now