blob: e95d08f6326f68721fd3165ea5e6666bfe26fe86 [file] [edit]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_TESTING_CATAPULT_CONVERTER_CONVERTER_H_
#define SRC_TESTING_CATAPULT_CONVERTER_CONVERTER_H_
#include <optional>
#include <span>
#include "rapidjson/document.h"
// Generate a 128-bit (pseudo) random UUID in the form of version 4 as described
// in RFC 4122, section 4.4.
// The format of UUID version 4 must be xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx,
// where y is one of [8, 9, A, B].
// The hexadecimal values "a" through "f" are output as lower case characters.
// If UUID generation fails an empty string is returned.
std::string GenerateUuid();
// Convert a fuchsiaperf unit into the corresponding catapult format. Additionally convert and
// modify `vls` to fit the new unit.
std::optional<std::string> ConvertUnits(std::string_view input_unit, std::span<double> vals);
struct ConverterArgs {
// These parameters are copied into the Catapult histogram file. See the
// README.md file for the meanings of these parameters.
int64_t timestamp = 0;
const char* masters = nullptr;
const char* bots = nullptr;
const char* log_url = nullptr;
const char* product_versions = nullptr;
const char* integration_internal_git_commit = nullptr;
const char* integration_public_git_commit = nullptr;
const char* smart_integration_git_commit = nullptr;
// Generate deterministic GUIDs instead of random GUIDs. This is used
// only for testing.
bool use_test_guids = false;
};
void Convert(rapidjson::Document* input, rapidjson::Document* output, const ConverterArgs* args);
int ConverterMain(int argc, char** argv);
#endif // SRC_TESTING_CATAPULT_CONVERTER_CONVERTER_H_