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
This commit is contained in:
Alex Ames
2015-02-13 15:58:29 -08:00
parent 620fe1c5cf
commit d575321eba
11 changed files with 333 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
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 @@ endif()
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 @@ set(FlatBuffers_Compiler_SRCS
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_Binary_SRCS
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 @@ endif(BIICODE)
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)