The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
swobject.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * swobject.cpp - code for SWClass used as lowest base class for many
4  * SWORD objects
5  *
6  * $Id: swobject.cpp 3810 2020-10-10 07:39:02Z scribe $
7  *
8  * Copyright 2005-2013 CrossWire Bible Society (http://www.crosswire.org)
9  * CrossWire Bible Society
10  * P. O. Box 2528
11  * Tempe, AZ 85280-2528
12  *
13  * This program is free software; you can redistribute it and/or modify it
14  * under the terms of the GNU General Public License as published by the
15  * Free Software Foundation version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but
18  * WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * General Public License for more details.
21  *
22  */
23 
24 #include <swobject.h>
25 
26 // hack. remove this when we figure out our link error
27 #ifndef __CYGWIN__
28 #include <utilstr.h>
29 #else
30 #include <string.h>
31 #endif
32 
33 
35 
36 
37 bool SWClass::isAssignableFrom(const char *className) const {
38  // skip class qualifier, like 'const VerseKey'
39  const char *space = strchr(className, ' ');
40  if (space) className = space + 1;
41  for (int i = 0; descends[i]; ++i) {
42 #ifndef __CYGWIN__
43  if (!sword::stricmp(descends[i], className))
44 #else
45  if (!stricmp(descends[i], className))
46 #endif
47  return true;
48  }
49  return false;
50 }
51 
52 /*
53 static const char *classes[] = {"SWObject", 0};
54 static const SWClass classdef(classes);
55 
56 SWObject::SWObject() {
57  myClass = &classdef;
58 }
59 */
60 
61 SWObject::SWObject(const SWClass &assignClassDef) {
62  myClass = &assignClassDef;
63 }
64 
65 
67 
#define SWORD_NAMESPACE_START
Definition: defs.h:39
bool isAssignableFrom(const char *className) const
Definition: swobject.cpp:37
const SWClass * myClass
Definition: swobject.h:55
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
SWObject(const SWClass &classdef)
Definition: swobject.cpp:61
#define SWORD_NAMESPACE_END
Definition: defs.h:40
const char ** descends
Definition: swobject.h:37