added headers
This commit is contained in:
parent
d17d9103de
commit
aa8beace98
@ -104,6 +104,11 @@ void HashTable::Clear()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HashTable::KeyExists(const char *key)
|
||||||
|
{
|
||||||
|
return _FindNode(key, false);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
// Iterator stuff //
|
// Iterator stuff //
|
||||||
////////////////////
|
////////////////////
|
||||||
@ -209,7 +214,7 @@ void HashTable::_Unlink(HashTable::htNodeSet *set, HashTable::htNode *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Finds a node by key
|
//Finds a node by key
|
||||||
HashTable::htNode *HashTable::_FindNode(const char *key)
|
HashTable::htNode *HashTable::_FindNode(const char *key, bool autoMake)
|
||||||
{
|
{
|
||||||
HashTable::htNodeSet *set;
|
HashTable::htNodeSet *set;
|
||||||
HashTable::htNode *node;
|
HashTable::htNode *node;
|
||||||
@ -224,7 +229,10 @@ HashTable::htNode *HashTable::_FindNode(const char *key)
|
|||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _InsertIntoNodeSet(set, key, true);
|
if (autoMake)
|
||||||
|
return _InsertIntoNodeSet(set, key, true);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Inserts a new set of data into a bucket
|
//Inserts a new set of data into a bucket
|
||||||
|
@ -42,6 +42,7 @@ public: //PUBLIC FUNCTIONS
|
|||||||
iterator Enumerate();
|
iterator Enumerate();
|
||||||
size_t Prune(time_t begin, time_t end, bool all=false);
|
size_t Prune(time_t begin, time_t end, bool all=false);
|
||||||
void Clear();
|
void Clear();
|
||||||
|
bool KeyExists(const char *key);
|
||||||
public: //PUBLIC CLASSES
|
public: //PUBLIC CLASSES
|
||||||
class iterator
|
class iterator
|
||||||
{
|
{
|
||||||
@ -62,7 +63,7 @@ public: //PUBLIC CLASSES
|
|||||||
};
|
};
|
||||||
private: //PRIVATE API
|
private: //PRIVATE API
|
||||||
void _Insert(const char *key, const char *val, time_t stamp);
|
void _Insert(const char *key, const char *val, time_t stamp);
|
||||||
htNode *_FindNode(const char *key);
|
htNode *_FindNode(const char *key, bool autoMake=true);
|
||||||
htNodeSet *_FindNodeSet(const char *key);
|
htNodeSet *_FindNodeSet(const char *key);
|
||||||
htNode *_InsertIntoNodeSet(htNodeSet *set, const char *key, bool skip=false);
|
htNode *_InsertIntoNodeSet(htNodeSet *set, const char *key, bool skip=false);
|
||||||
void _Unlink(htNodeSet *set, htNode *node);
|
void _Unlink(htNodeSet *set, htNode *node);
|
||||||
|
2
dlls/nvault/nvault.cpp
Executable file
2
dlls/nvault/nvault.cpp
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#include "nvault.h"
|
||||||
|
|
53
dlls/nvault/nvault.h
Executable file
53
dlls/nvault/nvault.h
Executable file
@ -0,0 +1,53 @@
|
|||||||
|
#ifndef _INCLUDE_NVAULT_H
|
||||||
|
#define _INCLUDE_NVAULT_H
|
||||||
|
|
||||||
|
#include "sdk/CString.h"
|
||||||
|
#include "hash.h"
|
||||||
|
|
||||||
|
class Journal
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum JournalOp
|
||||||
|
{
|
||||||
|
Journal_Store,
|
||||||
|
Journal_Erase,
|
||||||
|
Journal_Clear,
|
||||||
|
Journal_Prune
|
||||||
|
};
|
||||||
|
public:
|
||||||
|
Journal(const char *file);
|
||||||
|
public:
|
||||||
|
bool Replay(size_t &files, size_t &ops);
|
||||||
|
void Clear();
|
||||||
|
public:
|
||||||
|
void Begin(const char *name, JournalOp jop);
|
||||||
|
void WriteByte(uint8_t num);
|
||||||
|
void WriteInt(uint32_t num);
|
||||||
|
void WriteTime(time_t n);
|
||||||
|
void WriteString(const char *str);
|
||||||
|
size_t End();
|
||||||
|
private:
|
||||||
|
String m_File;
|
||||||
|
FILE *m_Fp;
|
||||||
|
size_t m_WriteSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
class nVault
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
nVault(const char *name);
|
||||||
|
public:
|
||||||
|
bool WriteToFile();
|
||||||
|
bool ReadFromFile();
|
||||||
|
public:
|
||||||
|
void Store(const char *key, const char *value, bool temporary=true);
|
||||||
|
size_t Prune(time_t begin, time_t end, bool all=false);
|
||||||
|
HashTable::htNode *Find(const char *key);
|
||||||
|
bool KeyExists(const char *key);
|
||||||
|
void Clear();
|
||||||
|
private:
|
||||||
|
String m_File;
|
||||||
|
HashTable *m_Vault;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_INCLUDE_NVAULT_H
|
@ -118,6 +118,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\hash.cpp">
|
RelativePath=".\hash.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\nvault.cpp">
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
@ -126,6 +129,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\hash.h">
|
RelativePath=".\hash.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\nvault.h">
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
|
Loading…
Reference in New Issue
Block a user