fix up MsdFile; get rid of arbitrary limits

This commit is contained in:
Glenn Maynard
2003-01-14 22:44:30 +00:00
parent e4f9a339af
commit 4f1455d30e
7 changed files with 67 additions and 71 deletions
+22 -21
View File
@@ -8,37 +8,38 @@
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
Glenn Maynard
-----------------------------------------------------------------------------
*/
const unsigned MAX_VALUES = 200;
const unsigned MAX_PARAMS_PER_VALUE = 10;
class MsdFile
{
public:
/* #param:param:param:param; <- one whole value */
struct value_t
{
vector<CString> params;
CString operator[](unsigned i) const { if(i >= params.size()) return ""; return params[i]; }
};
virtual ~MsdFile() { }
//returns true if successful, false otherwise
bool ReadFile( CString sFilePath );
unsigned GetNumValues() const { return values.size(); }
unsigned GetNumParams(unsigned val) const { if(val >= GetNumValues()) return 0; return values[val].params.size(); }
const value_t &GetValue(unsigned val) const { ASSERT(val < GetNumValues()); return values[val]; }
CString GetParam(unsigned val, unsigned par) const;
private:
void ReadBuf( char *buf, int len );
void AddParam( char *buf, int len );
void AddValue();
unsigned m_iNumValues; // tells how many values are valid
public:
MsdFile();
//default destructor
virtual ~MsdFile();
//reads ini file specified using MsdFile::SetPath()
//returns true if successful, false otherwise
bool ReadFile( CString sFilePath );
CString m_sParams[MAX_VALUES][MAX_PARAMS_PER_VALUE];
/* #param:param:param:param; <- one whole value */
unsigned m_iNumParams[MAX_VALUES]; // tells how many params this value has
unsigned GetNumValues() const { return m_iNumValues; }
vector<value_t> values;
};
#endif