00001 /* MsdFile - Read .SM, .DWI, and .MSD files. */ 00002 00003 #ifndef MSDFILE_H 00004 #define MSDFILE_H 00005 00006 class MsdFile 00007 { 00008 public: 00009 /* #param:param:param:param; <- one whole value */ 00010 struct value_t 00011 { 00012 vector<CString> params; 00013 00014 CString operator[](unsigned i) const { if(i >= params.size()) return ""; return params[i]; } 00015 }; 00016 00017 virtual ~MsdFile() { } 00018 00019 // Returns true if successful, false otherwise. 00020 bool ReadFile( CString sFilePath ); 00021 CString GetError() const { return error; } 00022 00023 unsigned GetNumValues() const { return values.size(); } 00024 unsigned GetNumParams(unsigned val) const { if(val >= GetNumValues()) return 0; return values[val].params.size(); } 00025 const value_t &GetValue(unsigned val) const { ASSERT(val < GetNumValues()); return values[val]; } 00026 CString GetParam(unsigned val, unsigned par) const; 00027 00028 00029 private: 00030 void ReadBuf( char *buf, int len ); 00031 void AddParam( char *buf, int len ); 00032 void AddValue(); 00033 00034 vector<value_t> values; 00035 CString error; 00036 }; 00037 00038 #endif 00039 00040 /* 00041 * (c) 2001-2004 Chris Danford, Glenn Maynard 00042 * 00043 * All rights reserved. 00044 * 00045 * Permission is hereby granted, free of charge, to any person obtaining a 00046 * copy of this software and associated documentation files (the 00047 * "Software"), to deal in the Software without restriction, including 00048 * without limitation the rights to use, copy, modify, merge, publish, 00049 * distribute, and/or sell copies of the Software, and to permit persons to 00050 * whom the Software is furnished to do so, provided that the above 00051 * copyright notice(s) and this permission notice appear in all copies of 00052 * the Software and that both the above copyright notice(s) and this 00053 * permission notice appear in supporting documentation. 00054 * 00055 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00056 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00057 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00058 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00059 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00060 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00061 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00062 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00063 * PERFORMANCE OF THIS SOFTWARE. 00064 */