For now, since you're just beginning, text files are probably OK. There's a couple of concerns in your question that I'll address.
Protecting the data isn't as crucial as you probably think. If your game is multiplayer, you'll have the data saved server-side anyways. If your game is single player, so what if players modify the data? If they break something it's really their fault and they can re-install.
Performance is also something else that we often fail to plan properly. You shouldn't really optimize until you actually measure a performance issue. My guess is that you'll probably have an amount of data that isn't that big and that text files are going to be just fine.
That being said, your best bet is to abstract your data saving and loading routines as best you can. For example, you can have a base class, say DataWriter
, and then provide different implementations of its different methods. A very basic example would look like:
class DataWriter {
virtual void save(GameState state) = 0;
virtual ~DataWriter() { }
};
class TextFileDataWriter : public DataWriter {
virtual void save(GameState state) {
//write to text file
}
};
class DatabaseDataWriter : public DataWriter {
virtual void save(GameState state) {
//write to database
}
};
When you eventually profile your game and realize the performance bottleneck is in the file writing routine, you can provide another implementation of that class (for example to write to a database instead) with minimal changes to calling code.