#ifndef SRC_CONFAB_CONFAB_VERSION_H_
#define SRC_CONFAB_CONFAB_VERSION_H_

#include "common/Version.hpp"

#include <cstdint>

namespace Confab {

const int kConfabVersionMajor = @CONFAB_VERSION_MAJOR@;
const int kConfabVersionMinor = @CONFAB_VERSION_MINOR@;
const int kConfabVersionPatch = @CONFAB_VERSION_PATCH@;

static const Common::Version confabVersion(kConfabVersionMajor, kConfabVersionMinor, kConfabVersionPatch);

// We assume that memory is allocated in 4K pages, meaning that keeping individual records at sizes smaller than 4K
// uncompressed will help the system manipulate small chunks efficiently. Because we also store a hash of each data
// chunk along with the chunk data itself, and there may be additional overhead in leveldb, flatbuffers, etc, we
// reserve a few bytes within the 4K to make sure we are actually fitting into that 4K limit.
constexpr size_t kPageSize = 4096;
// Because we have to base64 encode records for sending data via HTTP. The base64 expansion uses s = 4 * ((n / 3) + 1)
// bytes where n is input size. This means that max sizes need to be adjusted for padding by n = ((s / 4) - 1) * 3.
// These values have been adjusted heuristically to keep the maximum size of encoded data sent between HTTP client and
// server under 4096 bytes, as the HTTP client code will hang if that size is exceeded.
constexpr size_t kDataChunkSize = 3 * (((kPageSize - 256) / 4) - 1);
constexpr size_t kSingleChunkDataSize = 3 * (((3 * 1024) / 4) - 1);
constexpr size_t kMaxAssetSize = 4ull * 1024ull * 1024ull * 1024ull;

/*! Used as both key and timestamp to make a sentinel entry for the last element in a list, to allow reverse iteration
 * to this element as well as to have a way to return the last element.
 */
static constexpr size_t kEndList = std::numeric_limits<uint64_t>::max();
static constexpr size_t kBeginList = 0;

}  // namespace Confab

#endif  // SRC_CONFAB_CONFAB_VERSION_H_

