From aa8beace98e6a57811fd856c49c2f3ce8cb904a0 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 2 Apr 2005 16:04:08 +0000 Subject: [PATCH] added headers --- dlls/nvault/hash.cpp | 12 +++++++-- dlls/nvault/hash.h | 3 ++- dlls/nvault/nvault.cpp | 2 ++ dlls/nvault/nvault.h | 53 +++++++++++++++++++++++++++++++++++++++ dlls/nvault/nvault.vcproj | 6 +++++ 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100755 dlls/nvault/nvault.cpp create mode 100755 dlls/nvault/nvault.h diff --git a/dlls/nvault/hash.cpp b/dlls/nvault/hash.cpp index 92879c89..d58176ae 100755 --- a/dlls/nvault/hash.cpp +++ b/dlls/nvault/hash.cpp @@ -104,6 +104,11 @@ void HashTable::Clear() } } +bool HashTable::KeyExists(const char *key) +{ + return _FindNode(key, false); +} + //////////////////// // Iterator stuff // //////////////////// @@ -209,7 +214,7 @@ void HashTable::_Unlink(HashTable::htNodeSet *set, HashTable::htNode *node) } //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::htNode *node; @@ -224,7 +229,10 @@ HashTable::htNode *HashTable::_FindNode(const char *key) 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 diff --git a/dlls/nvault/hash.h b/dlls/nvault/hash.h index 5d9d2b0f..2f1548db 100755 --- a/dlls/nvault/hash.h +++ b/dlls/nvault/hash.h @@ -42,6 +42,7 @@ public: //PUBLIC FUNCTIONS iterator Enumerate(); size_t Prune(time_t begin, time_t end, bool all=false); void Clear(); + bool KeyExists(const char *key); public: //PUBLIC CLASSES class iterator { @@ -62,7 +63,7 @@ public: //PUBLIC CLASSES }; private: //PRIVATE API 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); htNode *_InsertIntoNodeSet(htNodeSet *set, const char *key, bool skip=false); void _Unlink(htNodeSet *set, htNode *node); diff --git a/dlls/nvault/nvault.cpp b/dlls/nvault/nvault.cpp new file mode 100755 index 00000000..97966a05 --- /dev/null +++ b/dlls/nvault/nvault.cpp @@ -0,0 +1,2 @@ +#include "nvault.h" + diff --git a/dlls/nvault/nvault.h b/dlls/nvault/nvault.h new file mode 100755 index 00000000..67199adf --- /dev/null +++ b/dlls/nvault/nvault.h @@ -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 diff --git a/dlls/nvault/nvault.vcproj b/dlls/nvault/nvault.vcproj index 45034268..0cc035d4 100755 --- a/dlls/nvault/nvault.vcproj +++ b/dlls/nvault/nvault.vcproj @@ -118,6 +118,9 @@ + + + +