Debian Codegraph @

Source/Reasoner/Triples/CRedlandNodeHasher.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20 #ifdef KONCLUDE_REDLAND_INTEGRATION
21
22 #include "CRedlandNodeHasher.h"
23
24
25 namespace Konclude {
26
27 namespace Reasoner {
28
29 namespace Triples {
30
31
32 CRedlandNodeHasher::CRedlandNodeHasher(librdf_node* node) {
33 mNode = librdf_new_node_from_node(node);
34 if (librdf_node_is_literal(mNode)) {
35 mHashValue = hash_c_string((const char*)librdf_node_get_literal_value(mNode));
36 } else if (!librdf_node_is_blank(node)) {
37 librdf_uri* uri = librdf_node_get_uri(mNode);
38 mHashValue = hash_c_string((const char*)librdf_uri_as_string(uri));
39 } else {
40 mHashValue = hash_c_string((const char*)librdf_node_get_blank_identifier(mNode));
41 }
42 }
43
44 CRedlandNodeHasher::CRedlandNodeHasher(const CRedlandNodeHasher& hasher) {
45 mNode = librdf_new_node_from_node(hasher.mNode);
46 mHashValue = hasher.mHashValue;
47 }
48
49
50 CRedlandNodeHasher& CRedlandNodeHasher::operator=(const CRedlandNodeHasher& hasher) {
51 mNode = librdf_new_node_from_node(hasher.mNode);
52 mHashValue = hasher.mHashValue;
53 return *this;
54 }
55
56 librdf_node* CRedlandNodeHasher::getRedlandNode() const {
57 return mNode;
58 }
59
60 CRedlandNodeHasher::~CRedlandNodeHasher() {
61 librdf_free_node(mNode);
62 }
63
64
65 }; // end namespace Triples
66
67 }; // end namespace Reasoner
68
69 }; // end namespace Konclude
70
71 #endif // !KONCLUDE_REDLAND_INTEGRATION