00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "vmsStringList.h"
00009
00010 #ifdef _DEBUG
00011 #undef THIS_FILE
00012 static char THIS_FILE[]=__FILE__;
00013 #define new DEBUG_NEW
00014 #endif
00015
00016 vmsStringList::vmsStringList()
00017 {
00018
00019 }
00020
00021 vmsStringList::~vmsStringList()
00022 {
00023
00024 }
00025
00026 void vmsStringList::Add(LPCSTR psz)
00027 {
00028 m_vList.add (psz);
00029 }
00030
00031 int vmsStringList::get_Count() const
00032 {
00033 return m_vList.size ();
00034 }
00035
00036 void vmsStringList::Del(int nIndex)
00037 {
00038 m_vList.del (nIndex);
00039 }
00040
00041 LPCSTR vmsStringList::get_String(int nIndex) const
00042 {
00043 const fs::list <fsString>* pv = &m_vList;
00044 return ((fs::list <fsString>*)pv)->at (nIndex);
00045 }
00046
00047 BOOL vmsStringList::Save(HANDLE hFile)
00048 {
00049 int c = m_vList.size ();
00050
00051 DWORD dw;
00052
00053 if (FALSE == WriteFile (hFile, &c, sizeof (c), &dw, NULL))
00054 return FALSE;
00055
00056 for (int i = 0; i < c; i++)
00057 {
00058 if (FALSE == fsSaveStrToFile (get_String (i), hFile))
00059 return FALSE;
00060 }
00061
00062 return TRUE;
00063 }
00064
00065 BOOL vmsStringList::Load(HANDLE hFile)
00066 {
00067 Clear ();
00068
00069 int c = 0;
00070 DWORD dw;
00071
00072 if (FALSE == ReadFile (hFile, &c, sizeof (c), &dw, NULL))
00073 return FALSE;
00074
00075 for (int i = 0; i < c; i++)
00076 {
00077 LPSTR psz;
00078
00079 if (FALSE == fsReadStrFromFile (&psz, hFile))
00080 return FALSE;
00081
00082 Add (psz);
00083
00084 delete [] psz;
00085 }
00086
00087 return TRUE;
00088 }
00089
00090 void vmsStringList::Clear()
00091 {
00092 m_vList.clear ();
00093 }