aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libbible.h
blob: f77dc8c3e88df7ac3d4707ff1f450a36f5a0bb06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <string>
#include <vector>
#include <map>

namespace libbible {

    struct text {
        int chapter;
        int verse;
        std::string book;
        std::string bookShort;
        std::string text;
        std::vector<std::string> modifiers; // e.g., paragraph, line indent0, divineName, wordsOfJesus
    };

    struct passage {
        std::string modName;
        std::string book;
        std::string bookShort;
        int chapterStart;
        int verseStart;
        int chapterEnd;
        int verseEnd;
    };

    /*
     * @return Map of modName to supported books
     */
    std::map<std::string, std::vector<std::string>> getModules(void);

    /*
     * @return Vector of valid single full-chapter passages for a book
     */
    std::vector<struct passage> getPassages(std::string modName, std::string book);

    /*
     * @param modName the module to use for determining the passage
     * @param reference a human-readable reference, e.g., "gen 1:26-27"
     * @return the passage matching the reference
     */
    passage getPassage(std::string modName, std::string reference);

    /*
     * @return Text for a passage
     */
    std::vector<struct text> getText(struct passage pass);

    /**************************
     * Methods dealing with mods
     ***************************/

    class Status {
        public:
            virtual void update(unsigned long totalBytes, unsigned long completedBytes, std::string message) {}
    };

    /**
     * @param status Status update method is called asynchronously as download progresses
     */
    void setStatusReporter(Status& status);

    /**
     * @return A mapping from language to bible version names
     */
    std::map<std::string, std::vector<std::string>> downloadModsAvailable();

    /**
     * @return A mapping from language abbreviations to full language names
     */
    std::map<std::string, std::string> getLanguageNames();

    /**
     * Cancel an in-progress download
     */
    void terminateDownload(void);

    /**
     * @param language The language of the mod to install as provided from downloadModsAvailable
     * @param name The name of the bible version as provided from downloadModsAvailable
     * @see downloadModsAvailable()
     * @return true on success, false otherwise
     */
    bool installModFromInternet(std::string language, std::string name);

    /**
     * @param filename Path to the .zip compressed module to be installed
     * @return true on success, false otherwise
     */
    bool installModFromZip(std::string filename);

    /**
     * @param modname The name of the module to be removed
     */
    void uninstallMod(std::string modname);

    /******************************
     * Methods dealing with settings
     *******************************/

    /*
     * From already established code, valid and useful values are:
     *    int fontsize: the last used size of the font
     *    string passage: the last looked-up passage
     *    string module: the last used module
     */

    void settingsWrite(std::string key, std::string value);

    std::string settingsRead(std::string key);

    void settingsWriteInt(std::string key, int value);

    int settingsReadInt(std::string key);

}