The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
emptyvss.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * emptyvss.cpp - Utility to list empty verses in a module
4  *
5  * $Id: emptyvss.cpp 3427 2016-07-03 14:30:33Z scribe $
6  *
7  * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
8  * CrossWire Bible Society
9  * P. O. Box 2528
10  * Tempe, AZ 85280-2528
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  */
22 
23 #ifdef _MSC_VER
24  #pragma warning( disable: 4251 )
25 #endif
26 
27 #include <swmgr.h>
28 #include <swmodule.h>
29 #include <versekey.h>
30 #include <iostream>
31 #include <stdio.h>
32 
33 #ifndef NO_SWORD_NAMESPACE
34 using sword::SWMgr;
35 using sword::VerseKey;
36 using sword::ModMap;
37 using sword::SWKey;
38 using sword::SWModule;
39 using sword::SW_POSITION;
40 #endif
41 
42 int main(int argc, char **argv) {
43  if (argc < 2) {
44  fprintf(stderr, "usage: %s <Mod Name>\n", argv[0]);
45  exit(-1);
46  }
47 
48  SWMgr mgr;
49 
50  ModMap::iterator it = mgr.Modules.find(argv[1]);
51  if (it == mgr.Modules.end()) {
52  fprintf(stderr, "error: %s: couldn't find module: %s \n", argv[0], argv[1]);
53  exit(-2);
54  }
55 
56  SWModule *mod = it->second;
57 
58  SWKey *key = (*mod);
59  VerseKey *vkey = 0;
60  SWTRY {
61  vkey = dynamic_cast<VerseKey *>(key);
62  }
63  SWCATCH (...) {}
64 
65  if (!vkey) {
66  fprintf(stderr, "error: %s: %s module is not keyed to verses \n", argv[0], argv[1]);
67  exit(-3);
68  }
69 
70  vkey->setIntros(false); // turn on mod/testmnt/book/chap headings
71 
72  (*mod) = TOP;
73 
74  while (!mod->popError()) {
75 
76  if (vkey->getVerse()) {
77  if (!mod->renderText().length()) {
78  std::cout << *vkey << std::endl;
79  }
80  (*mod)++;
81  }
82  }
83 }
#define TOP
Definition: swkey.h:68
Definition: swmgr.h:93
unsigned long length() const
Definition: swbuf.h:197
ModMap Modules
Definition: swmgr.h:322
int main(int argc, char **argv)
Definition: addcomment.cpp:32
#define SWTRY
Definition: defs.h:57
SWBuf renderText(const char *buf, int len=-1, bool render=true) const
Definition: swmodule.cpp:1038
virtual void setIntros(bool val)
Definition: versekey.cpp:1663
#define SWCATCH(x)
Definition: defs.h:58
virtual int getVerse() const
Definition: versekey.cpp:1534
virtual char popError()
Definition: swmodule.cpp:185
std::map< SWBuf, SWModule *, std::less< SWBuf > > ModMap
Definition: swmgr.h:74
Definition: swkey.h:77
SWMgr * mgr
Definition: installmgr.cpp:46