Skip to content

Commit

Permalink
Included full version uri in HDT,
Browse files Browse the repository at this point in the history
  • Loading branch information
Miel Vander Sande committed Jul 8, 2016
1 parent dbfcd84 commit 1e23041
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
14 changes: 14 additions & 0 deletions hdt-lib/include/HDTVersion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* The total version number is: v<HDT_version>.<INDEX_VERSION>.<RELEASE_VERSION>
*/

#ifndef HDT_HDTVERSION_HPP_
#define HDT_HDTVERSION_HPP_

// Version of the actual HDT file that is generated or read.
// Software must be backwards compatible with all HDT files with the same number.
#define HDT_VERSION "1"
Expand All @@ -37,3 +40,14 @@

// Subreleases that are backwards compatible with both HDT and index file
#define RELEASE_VERSION "1"

#include <string>

namespace hdt {
namespace HDTVersion {
inline std::string get_version_string(std::string delimiter) {
return std::string("v") + HDT_VERSION + delimiter + INDEX_VERSION + delimiter + RELEASE_VERSION;
};
}
}
#endif /* HDT_HDTVERSION_HPP_ */
3 changes: 2 additions & 1 deletion hdt-lib/include/HDTVocabulary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ namespace hdt {
namespace HDTVocabulary {
// Base
const std::string HDT_BASE = "<http://purl.org/HDT/hdt#";
const std::string HDT_CONTAINER = HDT_BASE+"HDTv"+HDT_VERSION+">";
const std::string HDT_CONTAINER = HDT_BASE+"HDTv" + HDTVersion::get_version_string("-") + ">";
const std::string HDT_CONTAINER_BASE = HDT_BASE+"HDTv" + HDT_VERSION;
const std::string HDT_HEADER = HDT_BASE+"header";
const std::string HDT_DICTIONARY_BASE = HDT_BASE+"dictionary";
const std::string HDT_DICTIONARY = HDT_DICTIONARY_BASE+">";
Expand Down
10 changes: 6 additions & 4 deletions hdt-lib/src/hdt/BasicHDT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,9 @@ void BasicHDT::loadFromHDT(std::istream & input, ProgressListener *listener)
// Load Global ControlInformation.
controlInformation.load(input);
std::string hdtFormat = controlInformation.getFormat();
if(hdtFormat!=HDTVocabulary::HDT_CONTAINER) {
throw std::runtime_error("This software cannot open this version of HDT File (" + hdtFormat + " =/= " + HDTVocabulary::HDT_CONTAINER + ")");
//if(hdtFormat!=HDTVocabulary::HDT_CONTAINER) {
if (hdtFormat.find(HDTVocabulary::HDT_CONTAINER_BASE) == std::string::npos) {
throw std::runtime_error("This software (v" + std::string(HDT_VERSION) + ".x.x) cannot open this version of HDT File (" + hdtFormat + ")");
}

// Load header
Expand Down Expand Up @@ -742,8 +743,9 @@ size_t BasicHDT::loadMMap(unsigned char *ptr, unsigned char *ptrMax, ProgressLis
// Load Global ControlInformation
count+=controlInformation.load(&ptr[count], ptrMax);
std::string hdtFormat = controlInformation.getFormat();
if(hdtFormat!=HDTVocabulary::HDT_CONTAINER) {
throw std::runtime_error("This software cannot open this version of HDT File (" + hdtFormat + " =/= " + HDTVocabulary::HDT_CONTAINER + ")");
//if(hdtFormat!=HDTVocabulary::HDT_CONTAINER) {
if (hdtFormat.find(HDTVocabulary::HDT_CONTAINER_BASE) == std::string::npos) {
throw std::runtime_error("This software (v" + std::string(HDT_VERSION) + ".x.x) cannot open this version of HDT File (" + hdtFormat + ")");
}

// Load Header
Expand Down
2 changes: 1 addition & 1 deletion hdt-lib/tools/hdt2rdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int main(int argc, char **argv) {
cout << "Format: " << rdfFormat << endl;
break;
case 'V':
cout << "v" << HDT_VERSION << "." << INDEX_VERSION << "." << RELEASE_VERSION << endl;
cout << HDTVersion::get_version_string(".") << endl;
return 0;
default:
cout << "ERROR: Unknown option" << endl;
Expand Down
2 changes: 1 addition & 1 deletion hdt-lib/tools/hdtInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main(int argc, char **argv) {
outputFile = optarg;
break;
case 'V':
cout << "v" << HDT_VERSION << "." << INDEX_VERSION << "." << RELEASE_VERSION << endl;
cout << HDTVersion::get_version_string(".") << endl;
return 0;
default:
cout << "ERROR: Unknown option" << endl;
Expand Down
2 changes: 1 addition & 1 deletion hdt-lib/tools/hdtSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int main(int argc, char **argv) {
measure = true;
break;
case 'V':
cout << "v" << HDT_VERSION << "." << INDEX_VERSION << "." << RELEASE_VERSION << endl;
cout << HDTVersion::get_version_string(".") << endl;
return 0;
default:
cout << "ERROR: Unknown option" << endl;
Expand Down
2 changes: 1 addition & 1 deletion hdt-lib/tools/rdf2hdt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int main(int argc, char **argv) {
generateIndex=true;
break;
case 'V':
cout << "v" << HDT_VERSION << "." << INDEX_VERSION << "." << RELEASE_VERSION << endl;
cout << HDTVersion::get_version_string(".") << endl;
return 0;
default:
cout << "ERROR: Unknown option" << endl;
Expand Down

0 comments on commit 1e23041

Please sign in to comment.