Skip to content

Commit 683aefe

Browse files
committed
fixing up todo comments; other code cleanup
1 parent 3f82cf7 commit 683aefe

14 files changed

+78
-93
lines changed

jsonld-cpp/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ set_target_properties(jsonld-cpp PROPERTIES CXX_EXTENSIONS OFF)
107107

108108
# Set version
109109

110-
target_compile_definitions(jsonld-cpp PRIVATE -DJSONLDCPP_VERSION_MAJOR=${JSONLDCPP_VERSION_MAJOR})
111-
target_compile_definitions(jsonld-cpp PRIVATE -DJSONLDCPP_VERSION_MINOR=${JSONLDCPP_VERSION_MINOR})
112-
target_compile_definitions(jsonld-cpp PRIVATE -DJSONLDCPP_VERSION_PATCH=${JSONLDCPP_VERSION_PATCH})
110+
target_compile_definitions(jsonld-cpp PRIVATE -DJSONLDCPP_VERSION=${JSONLDCPP_VERSION})
113111

114112
if(JSONLDCPP_BUILD_TESTS)
115113
enable_testing()

jsonld-cpp/Context.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ class Context {
6161

6262
std::string getDefaultBaseDirection() const; // used by expansion processor
6363

64-
const JsonLdOptions &getOptions() const;// used by expansion processor
64+
const JsonLdOptions &getOptions() const;// used by context and expansion processor
6565

6666
void setDefaultBaseDirection(const std::string & direction); // used by context processor
6767

68-
const nlohmann::ordered_json &getTermDefinitions() const;
68+
const nlohmann::ordered_json &getTermDefinitions() const; // used by context processor
6969

70-
nlohmann::ordered_json &getTermDefinitions() ;
70+
nlohmann::ordered_json &getTermDefinitions(); // used by context processor
7171
};
7272

7373
#endif //LIBJSONLD_CPP_CONTEXT_H

jsonld-cpp/ContextProcessor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef JSONLD_CPP_LIBRARY_CONTEXTPROCESSOR_H
2-
#define JSONLD_CPP_LIBRARY_CONTEXTPROCESSOR_H
1+
#ifndef LIBJSONLD_CPP_CONTEXTPROCESSOR_H
2+
#define LIBJSONLD_CPP_CONTEXTPROCESSOR_H
33

44
#include "jsonld-cpp/Context.h"
55
#include "jsonld-cpp/jsoninc.h"
@@ -38,4 +38,4 @@ struct ContextProcessor {
3838
};
3939

4040

41-
#endif //JSONLD_CPP_LIBRARY_CONTEXTPROCESSOR_H
41+
#endif //LIBJSONLD_CPP_CONTEXTPROCESSOR_H

jsonld-cpp/ExpansionProcessor.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,15 @@ namespace {
281281
return activeContext;
282282
}
283283

284-
void expandObjectElement_step13(const std::string *activeProperty, const json &element, const std::string &baseUrl,
285-
Context &typeScopedContext, const std::string &inputType, Context &activeContext, json &result,
286-
json &nests);
284+
void expandObjectElement_step13(
285+
const std::string *activeProperty, const json &element, const std::string &baseUrl,
286+
Context &typeScopedContext, const std::string &inputType, Context &activeContext, json &result,
287+
json &nests);
287288

288-
void expandObjectElement_step14(Context &activeContext, const std::string *activeProperty, const json &element,
289-
const std::string &baseUrl, Context &typeScopedContext, json &result,
290-
json &nests, const std::string &inputType);
289+
void expandObjectElement_step14(
290+
Context &activeContext, const json &element,
291+
const std::string &baseUrl, Context &typeScopedContext, json &result,
292+
json &nests, const std::string &inputType);
291293

292294
json expandObjectElement(
293295
Context activeContext,
@@ -366,7 +368,7 @@ namespace {
366368

367369
// 14)
368370
// For each key nesting-key in nests, ordered lexicographically if ordered is true:
369-
expandObjectElement_step14(activeContext, activeProperty, element, baseUrl, typeScopedContext, result,
371+
expandObjectElement_step14(activeContext, element, baseUrl, typeScopedContext, result,
370372
nests, inputType);
371373

372374
// 15)
@@ -1009,7 +1011,7 @@ namespace {
10091011
for (json::iterator it = element_value.begin(); it != element_value.end(); ++it) {
10101012
value_keys.push_back(it.key());
10111013
}
1012-
// todo: if I comment the next line then I fix 7 tests, but that doesn't seem right
1014+
10131015
if(activeContext.getOptions().isOrdered())
10141016
std::sort(value_keys.begin(), value_keys.end());
10151017

@@ -1349,7 +1351,7 @@ namespace {
13491351
}
13501352
}
13511353

1352-
void expandObjectElement_step14(Context &activeContext, const std::string *activeProperty, const json &element,
1354+
void expandObjectElement_step14(Context &activeContext, const json &element,
13531355
const std::string &baseUrl, Context &typeScopedContext, json &result,
13541356
json &nests, const std::string &inputType) {
13551357
// 14)
@@ -1421,7 +1423,7 @@ namespace {
14211423

14221424
// 14)
14231425
// For each key nesting-key in nests, ordered lexicographically if ordered is true:
1424-
expandObjectElement_step14(copyActiveContext, &nestingKey, nestedValue, baseUrl, typeScopedContext, result,
1426+
expandObjectElement_step14(copyActiveContext, nestedValue, baseUrl, typeScopedContext, result,
14251427
localNests, inputType);
14261428

14271429
}
@@ -1450,7 +1452,7 @@ json ExpansionProcessor::expand(
14501452
// 2)
14511453
// If active property is @default, initialize the frameExpansion flag to false.
14521454
if (activeProperty != nullptr && *activeProperty == JsonLdConsts::DEFAULT) {
1453-
//todo: activeContext.getOptions().setFrameExpansion(false);
1455+
// todo: activeContext.getOptions().setFrameExpansion(false);
14541456
}
14551457

14561458
// 3)

jsonld-cpp/ExpansionProcessor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef JSONLD_CPP_LIBRARY_EXPANSIONPROCESSOR_H
2-
#define JSONLD_CPP_LIBRARY_EXPANSIONPROCESSOR_H
1+
#ifndef LIBJSONLD_CPP_EXPANSIONPROCESSOR_H
2+
#define LIBJSONLD_CPP_EXPANSIONPROCESSOR_H
33

44
#include "jsonld-cpp/jsoninc.h"
55

@@ -34,4 +34,4 @@ struct ExpansionProcessor {
3434
};
3535

3636

37-
#endif //JSONLD_CPP_LIBRARY_EXPANSIONPROCESSOR_H
37+
#endif //LIBJSONLD_CPP_EXPANSIONPROCESSOR_H

jsonld-cpp/JsonLdOptions.cpp

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
#include "jsonld-cpp/JsonLdOptions.h"
22

3-
4-
// definitions needed here for static members (though not necessary in c++17)
5-
//constexpr const char JsonLdOptions::JSON_LD_1_0[];
6-
//constexpr const char JsonLdOptions::JSON_LD_1_1[];
7-
//constexpr bool JsonLdOptions::DEFAULT_COMPACT_ARRAYS;
8-
9-
bool JsonLdOptions::isFrameExpansion() const {
10-
return frameExpansion_;
11-
}
12-
13-
void JsonLdOptions::setFrameExpansion(bool frameExpansion) {
14-
frameExpansion_ = frameExpansion;
15-
}
16-
17-
bool JsonLdOptions::isOrdered() const {
18-
return ordered_;
19-
}
20-
21-
void JsonLdOptions::setOrdered(bool ordered) {
22-
ordered_ = ordered;
23-
}
24-
25-
const std::string &JsonLdOptions::getHashAlgorithm() const {
26-
return hashAlgorithm_;
27-
}
28-
29-
void JsonLdOptions::setHashAlgorithm(const std::string &hashAlgorithm) {
30-
hashAlgorithm_ = hashAlgorithm;
31-
}
3+
//
4+
//bool JsonLdOptions::isFrameExpansion() const {
5+
// return frameExpansion_;
6+
//}
7+
//
8+
//void JsonLdOptions::setFrameExpansion(bool frameExpansion) {
9+
// frameExpansion_ = frameExpansion;
10+
//}
11+
//
12+
//bool JsonLdOptions::isOrdered() const {
13+
// return ordered_;
14+
//}
15+
//
16+
//void JsonLdOptions::setOrdered(bool ordered) {
17+
// ordered_ = ordered;
18+
//}
19+
//
20+
//const std::string &JsonLdOptions::getHashAlgorithm() const {
21+
// return hashAlgorithm_;
22+
//}
23+
//
24+
//void JsonLdOptions::setHashAlgorithm(const std::string &hashAlgorithm) {
25+
// hashAlgorithm_ = hashAlgorithm;
26+
//}
3227
//todo: why are these functions defined here? can they just all be in the header file?

jsonld-cpp/JsonLdOptions.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,21 @@ class JsonLdOptions {
159159
return *this;
160160
}
161161

162-
bool isFrameExpansion() const;
162+
bool isFrameExpansion() const {
163+
return frameExpansion_;
164+
}
163165

164-
void setFrameExpansion(bool frameExpansion);
166+
void setFrameExpansion(bool frameExpansion) {
167+
frameExpansion_ = frameExpansion;
168+
}
165169

166-
bool isOrdered() const;
170+
bool isOrdered() const {
171+
return ordered_;
172+
}
167173

168-
void setOrdered(bool ordered);
174+
void setOrdered(bool ordered) {
175+
ordered_ = ordered;
176+
}
169177

170178
bool getCompactArrays() const {
171179
return compactArrays_;
@@ -197,9 +205,6 @@ class JsonLdOptions {
197205

198206
void setProcessingMode(const std::string& processingMode) {
199207
this->processingMode_ = processingMode;
200-
// if (processingMode == JsonLdConsts::JSON_LD_1_1) {
201-
// omitGraph_ = true;
202-
// }
203208
}
204209

205210
std::string getBase() const {
@@ -250,9 +255,13 @@ class JsonLdOptions {
250255
this->documentLoader_ = std::move(documentLoader);
251256
}
252257

253-
const std::string &getHashAlgorithm() const;
258+
const std::string &getHashAlgorithm() const {
259+
return hashAlgorithm_;
260+
}
254261

255-
void setHashAlgorithm(const std::string &hashAlgorithm);
262+
void setHashAlgorithm(const std::string &hashAlgorithm) {
263+
hashAlgorithm_ = hashAlgorithm;
264+
}
256265

257266
};
258267

jsonld-cpp/JsonLdProcessor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ RDFDataset JsonLdProcessor::toRDF(const std::string& documentLocation, JsonLdOpt
127127

128128
// 1)
129129
// Create a new Promise promise and return it. The following steps are then deferred.
130-
// Note: we do not feel Promises are appropriate in this spec
131-
// todo: word more nicely and make sure you denote personal notes from spec notes
130+
// Note: the current implementation of jsonld-cpp does not use Promises.
132131

133132
// 2)
134133
// Set expanded input to the result of using the expand() method using input and options

jsonld-cpp/RDFSerializationProcessor.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ namespace {
161161
if (!graph.contains(id)) {
162162
json tmp = { { JsonLdConsts::ID, id } };
163163
graph[id] = tmp;
164-
// knowing the insertion order comes in handy later in RDFDataset::graphToRDF()
165-
// todo: does it still come in handy?
166-
graph["key_insertion_order"].push_back(id);
167164
}
168165
// 6.4)
169166
// Reference the value of the id entry of graph using the variable node.
@@ -653,9 +650,7 @@ namespace {
653650
// For each subject and node in graph ordered by subject:
654651
std::vector<std::string> subjects;
655652
for (auto& el : graph.items()) {
656-
// skip the key_insertion_order helper we added in generateNodeMap()
657-
if(el.key() != "key_insertion_order") // todo: do i still need to bother with the key insertion order?
658-
subjects.push_back(el.key());
653+
subjects.push_back(el.key());
659654
}
660655
std::sort(subjects.begin(), subjects.end());
661656

jsonld-cpp/RDFSerializationProcessor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef JSONLD_CPP_LIBRARY_RDFSERIALIZATIONPROCESSOR_H
2-
#define JSONLD_CPP_LIBRARY_RDFSERIALIZATIONPROCESSOR_H
1+
#ifndef LIBJSONLD_CPP_RDFSERIALIZATIONPROCESSOR_H
2+
#define LIBJSONLD_CPP_RDFSERIALIZATIONPROCESSOR_H
33

44
#include "jsonld-cpp/jsoninc.h"
55

@@ -28,4 +28,4 @@ struct RDFSerializationProcessor {
2828
};
2929

3030

31-
#endif //JSONLD_CPP_LIBRARY_RDFSERIALIZATIONPROCESSOR_H
31+
#endif //LIBJSONLD_CPP_RDFSERIALIZATIONPROCESSOR_H

0 commit comments

Comments
 (0)