Debian Codegraph @

Source/Reasoner/Ontology/CDataLiteral.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
21 #include "CDataLiteral.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Ontology {
29
30 CDataLiteral::CDataLiteral(CContext* context) {
31 mContext = context;
32 mDatatype = nullptr;
33 mDataValue = nullptr;
34 mLexicalLiteralStringByteDataArray = nullptr;
35 mLexicalLiteralStringByteDataArraySize = 0;
36 }
37
38 CDataLiteral::~CDataLiteral() {
39 CObjectAllocator<QChar>::destroyAndReleaseArray(mLexicalLiteralStringByteDataArray, CContext::getMemoryAllocationManager(mContext));
40 }
41
42
43 CDataLiteral* CDataLiteral::initDataLiteral(const QString& lexicalDataLiteralValueString, CDatatype* datatype) {
44 mLexicalLiteralStringByteDataArray = createStringByteDataArray(lexicalDataLiteralValueString);
45 mLexicalLiteralStringByteDataArraySize = lexicalDataLiteralValueString.length();
46 mDatatype = datatype;
47 mDataValue = nullptr;
48 return this;
49 }
50
51 QString CDataLiteral::getLexicalDataLiteralValueString() {
52 return QString(mLexicalLiteralStringByteDataArray, mLexicalLiteralStringByteDataArraySize);
53 }
54
55 CDatatype* CDataLiteral::getDatatype() {
56 return mDatatype;
57 }
58
59 CDataLiteralValue* CDataLiteral::getDataLiteralValue() {
60 return mDataValue;
61 }
62
63 CDataLiteral* CDataLiteral::setDataLiteralValue(CDataLiteralValue* dataValue) {
64 mDataValue = dataValue;
65 return this;
66 }
67
68 QChar* CDataLiteral::createStringByteDataArray(const QString& string) {
69 QChar* stringByteDataArrayCopy = CObjectAllocator<QChar>::allocateArray(CContext::getMemoryAllocationManager(mContext), string.length());
70 const QChar* stringData = string.constData();
71 for (cint64 i = 0; i < string.length(); ++i) {
72 stringByteDataArrayCopy[i] = stringData[i];
73 }
74 return stringByteDataArrayCopy;
75 }
76
77 }; // end namespace Ontology
78
79 }; // end namespace Reasoner
80
81 }; // end namespace Konclude