2
* Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
3
* CrossWire Bible Society
7
* This program is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License as published by the
9
* Free Software Foundation version 2.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
18
#include <entriesblk.h>
25
#ifndef NO_SWORD_NAMESPACE
26
using namespace sword;
29
void addEntry(EntriesBlock *eb) {
33
std::cout << "\nEnter new Entry's text. '.' on an empty line to finish:\n";
36
fgets(line, 1000, stdin);
38
if (input.compare("."))
41
while (input.compare("."));
42
std::cout << "Adding new entry. Index is: " << eb->addEntry(body.c_str()) << "\n\n";
46
void printEntry(EntriesBlock *eb, int index) {
47
if (index < eb->getCount()) {
48
std::cout << "Contents of entry [" << index << "]:\n";
49
std::cout << eb->getEntry(index) << "\n";
51
else std::cout << "Invalid entry number\n\n";
55
void printSize(EntriesBlock *eb) {
57
eb->getRawData(&size);
58
std::cout << "Size of raw data: " << size << "\n\n";
62
void removeEntry(EntriesBlock *eb, int index) {
63
if (index < eb->getCount()) {
64
std::cout << "Removing entry [" << index << "]\n";
65
eb->removeEntry(index);
67
else std::cout << "Invalid entry number\n\n";
71
int main(int argc, char **argv) {
73
EntriesBlock *eb = new EntriesBlock();
77
std::cout << "Initial entry count should be 0: " << eb->getCount() << "\n";
80
std::cout << "[" << eb->getCount() << "] > ";
81
fgets(line, 1000, stdin);
83
if (input.length() > 0) {
85
case 'a': addEntry(eb); break;
86
case 'p': printEntry(eb, atoi(input.c_str()+1)); break;
87
case 'r': removeEntry(eb, atoi(input.c_str()+1)); break;
88
case 's': printSize(eb); break;
92
std::cout << "\n a - add a new entry\n";
93
std::cout << " p <entry_index> - print entry\n";
94
std::cout << " r <entry_index> - remove entry\n";
95
std::cout << " s - print size of raw data\n";
96
std::cout << " q - quit\n\n";
101
while (input.compare("q"));