blob: 3081f57bcd9f4c07cf2ad2773c9ac1010a72cd74 [file] [log] [blame]
# Copyright 2019 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.
#!/bin/bash
# This file takes an output file as its first parameter, followed by one or more
# FIDL schema files in JSON format. It then generates a header containing a C++
# map from schema filename to file contents, which can then be used for test
# purposes.
set -e
FILENAME="${1}"
shift
rm -f "${FILENAME}"
cat > "${FILENAME}" << EOF
#include <map>
#include <string>
// Autogenerated: Do not modify!
namespace fidlcat_test {
class ExampleMap {
public:
ExampleMap() {
map_ = {
EOF
for i in "$@"; do \
cat >> "${FILENAME}" << EOF
{"${i}", R"FIDL($(cat "${i}"))FIDL"},
EOF
done
cat >> "${FILENAME}" << EOF
};
}
std::map<std::string, std::string> &map() { return map_; }
private:
std::map<std::string, std::string> map_;
};
} // namespace fidlcat_test
EOF