Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
BibleIO.h
00001 /* Bible I/O Class Definition 00002 * 00003 * Copyright (c) 2011 David R. Van Wagner davervw@yahoo.com 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining a copy 00006 * of this software and associated documentation files (the "Software"), to deal 00007 * in the Software without restriction, including without limitation the rights 00008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 * copies of the Software, and to permit persons to whom the Software is 00010 * furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be included in 00013 * all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 * THE SOFTWARE. 00022 */ 00023 00024 /* 00025 * This class assumes bible text file is present and in a specific format extracted from source such as: 00026 * http://printkjv.ifbweb.com/AV_txt.zip 00027 */ 00028 00029 #ifndef BIBLE_H 00030 #define BIBLE_H 00031 00032 #include "stdio.h" 00033 00034 class BibleIO 00035 { 00036 00037 public: 00038 BibleIO(char* text_filename, void (*indexing_callback)(int, void*), void* indexing_context); 00039 ~BibleIO(); 00040 short get_num_books(); 00041 short get_num_chapters(short book); 00042 short get_num_verses(short book, short chapter); 00043 char* title(); 00044 char* title_book(short book); 00045 char* title_chapter(short book, short chapter); 00046 char* text_chapter(short book, short chapter); 00047 char* text_verse(short book, short chapter, short verse); 00048 bool bookmark_add(short book, short chapter, short verse); 00049 bool bookmark_del(short book, short chapter, short verse); 00050 bool bookmark_prev(short &book, short &chapter, short &verse); 00051 bool bookmark_next(short &book, short &chapter, short &verse); 00052 00053 private: 00054 struct chapter_index 00055 { 00056 long title_offset; 00057 long verses_offset[]; 00058 }; 00059 00060 struct book_index 00061 { 00062 long title_offset; 00063 long num_chapters; 00064 }; 00065 00066 struct bible_index 00067 { 00068 long title_offset; 00069 book_index books[]; 00070 }; 00071 00072 struct position 00073 { 00074 short book; 00075 short chapter; 00076 short verse; 00077 short rsvd; // for padding 00078 }; 00079 00080 char* text_filename; 00081 FILE* fp; 00082 char* name; 00083 bible_index* books; 00084 short num_books; 00085 position* bookmarks; 00086 short num_bookmarks; 00087 void (*indexing_callback)(int, void*); 00088 void* indexing_context; 00089 00090 void build_index(); 00091 void read_name(); 00092 void format_book_name(char* &book_name); 00093 void read_preface(); 00094 void read_books(); 00095 bool read_book(FILE* index, short book); 00096 bool read_chapter(short book, short chapter); 00097 bool read_verse(FILE* index, short book, short chapter, short verse); 00098 char* read_line(); 00099 bool load_index(); 00100 bool load_bookmarks(); 00101 bool save_bookmarks(); 00102 char* index_path(); 00103 char* index_path(char* name); 00104 char* index_path(short chapter); 00105 char* index_path(short book, short chapter); 00106 }; 00107 00108 #endif
Generated on Sun Jul 24 2022 02:23:45 by
1.7.2