diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-16 15:24:24 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-16 15:24:24 +0200 |
commit | ab621173afc918797a4ea68b5d6ceee7cc043f72 (patch) | |
tree | e347f9ff7b8139851e69a84b58717a93e957ab92 /c/data.h | |
parent | 1cb00589065fd05b8d7cf0030eed84c488e9634d (diff) | |
download | EpisodeBrowser-ab621173afc918797a4ea68b5d6ceee7cc043f72.tar.gz |
Add data migration test.
Diffstat (limited to 'c/data.h')
-rw-r--r-- | c/data.h | 42 |
1 files changed, 22 insertions, 20 deletions
@@ -5,27 +5,29 @@ #include "util.h" #include "wcharptr.h" -/* ElvData and DlvData are written as-is to disk; note the careful - * alignment. */ +/* ElvDataA and DlvDataA are written as-is to disk; note the careful + * alignment. As such, they should be regarded as immutable. If the + * format needs to be changed in the future, then new structs called + * ElvDataB and DlvDataB should be added. */ -struct ElvData +struct ElvDataA { - unsigned char version = 'a'; /* 0-1 */ - unsigned char rating = 0; /* 1-2 */ - unsigned char bWatched = 0; /* 2-3 */ - unsigned char bTVOriginal = 0; /* 3-4 */ - wchar_t sRating[4] = {0}; /* 4-12 */ - wchar_t siEp[6] = {0}; /* 12-24 */ - wchar_t title[128] = {0}; /* 24-280 */ + unsigned char version = 'a'; + unsigned char rating = 0; + unsigned char bWatched = 0; + unsigned char bTVOriginal = 0; + wchar_t sRating[4] = {0}; + wchar_t siEp[6] = {0}; + wchar_t title[128] = {0}; }; -struct DlvData +struct DlvDataA { - wchar_t date[64] = {0}; - wchar_t source[64] = {0}; - wchar_t screenwriter[64] = {0}; + wchar_t date[32] = {0}; + wchar_t source[48] = {0}; + wchar_t screenwriter[48] = {0}; wchar_t hint[128] = {0}; - wchar_t wiki[128] = {0}; + wchar_t wiki[192] = {0}; }; struct FileView @@ -39,10 +41,10 @@ struct FileView /* TODO: Handle exceptions on read and write... */ }; -void Write(unsigned char* buf, const ElvData& e); -ElvData* Read(unsigned char* buf); +void Write(unsigned char* buf, const ElvDataA& e); +ElvDataA* Read(unsigned char* buf); -inline int FromWeb(const int iEp, ElvData& e, DlvData& d) noexcept +inline int FromWeb(const int iEp, ElvDataA& e, DlvDataA& d) noexcept { WcharPtr title, wiki, date, source, hint; const int r = Pl("episode_data","fetch_episode_data",iEp,&title,&wiki,&date,&source,&hint); @@ -54,7 +56,7 @@ inline int FromWeb(const int iEp, ElvData& e, DlvData& d) noexcept return r; } -inline bool FromProlog(const int iEp, ElvData& e) noexcept +inline bool FromProlog(const int iEp, ElvDataA& e) noexcept { if (WcharPtr title; Pl("episode_data","episode_title",iEp,&title)) Wcscpy(e.title, title); @@ -75,7 +77,7 @@ inline bool FromProlog(const int iEp, ElvData& e) noexcept return true; } -inline void FromProlog(const int iEp, DlvData& d) noexcept +inline void FromProlog(const int iEp, DlvDataA& d) noexcept { if (WcharPtr wiki; Pl("episode_data","episode_wiki",iEp,&wiki)) Wcscpy(d.wiki, wiki); |