Added the hash attribute to ints and longs.
FlatBuffer schema files can now optionally specify a hash attribute that
will allow someone writing json files to enter a string to be hashed
rather than a specific value. The hashing algorithm to use is specified
by the schema.
Currently the only algorithms are fnv1 and fnv1a. There are 32 bit and
64 variatns for each. Additionally, a hashing command line tool was
added so that you can see what a string will hash to without needing to
inspect the flatbuffer binary blob.
Change-Id: I0cb359d0e2dc7d2dc1874b446dc19a17cc77109d
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 823de9c..a746a64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@
option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON)
option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" ON)
+option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON)
if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS)
message(WARNING
@@ -16,6 +17,7 @@
set(FlatBuffers_Compiler_SRCS
include/flatbuffers/flatbuffers.h
+ include/flatbuffers/hash.h
include/flatbuffers/idl.h
include/flatbuffers/util.h
src/idl_parser.cpp
@@ -27,8 +29,14 @@
src/flatc.cpp
)
+set(FlatHash_SRCS
+ include/flatbuffers/hash.h
+ src/flathash.cpp
+)
+
set(FlatBuffers_Tests_SRCS
include/flatbuffers/flatbuffers.h
+ include/flatbuffers/hash.h
include/flatbuffers/idl.h
include/flatbuffers/util.h
src/idl_parser.cpp
@@ -48,6 +56,7 @@
set(FlatBuffers_Sample_Text_SRCS
include/flatbuffers/flatbuffers.h
+ include/flatbuffers/hash.h
include/flatbuffers/idl.h
include/flatbuffers/util.h
src/idl_parser.cpp
@@ -83,7 +92,11 @@
include_directories(include)
if(FLATBUFFERS_BUILD_FLATC)
-add_executable(flatc ${FlatBuffers_Compiler_SRCS})
+ add_executable(flatc ${FlatBuffers_Compiler_SRCS})
+endif()
+
+if(FLATBUFFERS_BUILD_FLATC)
+ add_executable(flathash ${FlatHash_SRCS})
endif()
function(compile_flatbuffers_schema_to_cpp SRC_FBS)