Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
74 lines
1.8 KiB
C++
74 lines
1.8 KiB
C++
#ifndef _DELIMITED_FILE_H_
|
|
#define _DELIMITED_FILE_H_
|
|
|
|
#include <cstdio>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
class CTokenlizedFile
|
|
{
|
|
public:
|
|
|
|
CTokenlizedFile(const char* lpszDelimiter = "\t");
|
|
~CTokenlizedFile();
|
|
|
|
enum
|
|
{
|
|
MAX_DELIMITER_NUM = 16,
|
|
MAX_LINE_BUFFER = 16384,
|
|
DEFAULT_COLUMN_NUM = 64
|
|
};
|
|
|
|
bool Open(const char* szFilename, const char* szOpenMode = "rt");
|
|
void Close();
|
|
|
|
bool ReadColumn(); // 컬럼 이름을 읽는다.
|
|
bool ReadLine(); // 한 라인을 읽는다.
|
|
|
|
bool IsEOF() { return (NULL != m_lpFile) ? (0 != feof(m_lpFile)) : false; }
|
|
|
|
size_t GetColumnNum() { return m_ColumnInfo.size(); }
|
|
size_t GetCurrentLine() { return m_nLine; }
|
|
size_t GetValueNum() { return m_ColumnValues.size(); }
|
|
|
|
const char* GetColumnName(size_t nIndex);
|
|
const char* GetStringValue(size_t nIndex);
|
|
const char* GetStringValue(const char* szColumnName);
|
|
|
|
private:
|
|
|
|
struct ColumnInfo
|
|
{
|
|
unsigned long m_dwHashKey;
|
|
std::string m_szColumnName;
|
|
|
|
ColumnInfo() : m_dwHashKey(0) { m_szColumnName.assign(""); }
|
|
ColumnInfo(const char* szColumnName);
|
|
ColumnInfo(std::string& szColumnName);
|
|
};
|
|
|
|
FILE* m_lpFile;
|
|
size_t m_nLine;
|
|
char m_szDelimiter[MAX_DELIMITER_NUM];
|
|
|
|
typedef std::vector<ColumnInfo> ColumnArray;
|
|
typedef std::vector<std::string> ValueArray;
|
|
|
|
ColumnArray m_ColumnInfo;
|
|
ValueArray m_ColumnValues;
|
|
};
|
|
|
|
|
|
inline const char* CTokenlizedFile::GetColumnName(size_t nIndex)
|
|
{
|
|
return (nIndex < m_ColumnInfo.size()) ?
|
|
m_ColumnInfo[nIndex].m_szColumnName.c_str() : NULL;
|
|
}
|
|
|
|
inline const char* CTokenlizedFile::GetStringValue(size_t nIndex)
|
|
{
|
|
return (nIndex < m_ColumnValues.size()) ?
|
|
m_ColumnValues[nIndex].c_str() : NULL;
|
|
}
|
|
|
|
#endif |