notepad_filestore.h

Go to the documentation of this file.
00001 #ifndef __NOTEPAD_FILESTORE_H__
00002 #define __NOTEPAD_FILESTORE_H__
00003 
00004 /**
00005  * File Name  : notepad_filestore.h
00006  *
00007  * Description: open/close file and file generation abstraction
00008  */
00009 
00010 /*
00011  * This file is part of notepad.
00012  *
00013  * notepad is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation, either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * notepad is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 /**
00028  * Copyright (C) 2010 IREX Technologies B.V.
00029  * All rights reserved.
00030  */
00031 
00032 #include <libermetadb/ermetadb.h>
00033 
00034 
00035 namespace notepad
00036 {
00037     // file (meta) handling
00038     // abstracts file creation and db file create/open interaction
00039     // collaborates with CNotepadDoc
00040 
00041     class CFileStore 
00042     {
00043         public: // lifecycle
00044             CFileStore ();
00045             virtual ~CFileStore ();
00046         private: // don'ts
00047             CFileStore(const CFileStore&);
00048             CFileStore  operator=(const CFileStore&);
00049         private:
00050             np_result   openDatabase(const gchar* folder, const gchar* filename);
00051             void        closeDatabase(void);
00052             np_result   createDatabase(const gchar* folder, const gchar* file, const char* title);
00053             np_result   renameDatabase(const gchar* srcdir, const gchar* srcfile, const gchar* destfile);
00054         public:
00055             np_result   createFile(const gchar* filename);
00056             np_result   openFile(const gchar* filename);
00057             void        closeFile();
00058             np_result   renameFile(const gchar* newfilename);
00059             gchar*      getFilename(void);
00060             erMetadb    getFile(void);
00061         public: // utility functions
00062             gchar*      getFileNameDirPart(void);       // caller takes ownership of returned object
00063             gchar*      getFileNameFilePart(void);      // caller takes ownership of returned object
00064             gchar*      getFileNameFilePartNoExt(void); // caller takes ownership of returned object
00065         private:
00066             gchar*      generateNewFilename(void);
00067             gchar*      noExt(const char* filename);
00068         private:
00069             // database actions
00070             gboolean    load_string(const char *key, gchar** value);
00071             gboolean    save_string(const char *key, const gchar* value);
00072         public:
00073             gint        get_last_read_location(void);
00074             gboolean    set_last_read_location(gint location);
00075 
00076         private:
00077             erMetadb    m_db;
00078             gchar*      m_dbfilename; 
00079     };
00080 }
00081 
00082 
00083 #endif // __NOTEPAD_FILESTORE_H__
Generated by  doxygen 1.6.2-20100208