1// This file is generated by Exported_h.template. 2 3// Copyright (c) 2016 The Chromium Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style license that can be 5// found in the LICENSE file. 6 7#ifndef {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_api_h 8#define {{"_".join(config.protocol.namespace)}}_{{domain.domain}}_api_h 9 10{% if config.exported.export_header %} 11#include {{format_include(config.exported.export_header)}} 12{% endif %} 13#include {{format_include(config.exported.string_header)}} 14 15{% for namespace in config.protocol.namespace %} 16namespace {{namespace}} { 17{% endfor %} 18 19#ifndef {{"_".join(config.protocol.namespace)}}_exported_api_h 20#define {{"_".join(config.protocol.namespace)}}_exported_api_h 21class {{config.exported.export_macro}} Exported { 22public: 23 virtual {{config.exported.string_out}} toJSONString() const = 0; 24 virtual void writeBinary(std::vector<uint8_t>* out) const = 0; 25 virtual ~Exported() { } 26}; 27#endif // !defined({{"_".join(config.protocol.namespace)}}_exported_api_h) 28 29namespace {{domain.domain}} { 30namespace API { 31 32// ------------- Enums. 33 {% for type in domain.types %} 34 {% if ("enum" in type) and protocol.is_exported(domain.domain, type.id) %} 35 36namespace {{type.id}}Enum { 37 {% for literal in type.enum %} 38{{config.exported.export_macro}} extern const char* {{ literal | dash_to_camelcase}}; 39 {% endfor %} 40} // {{type.id}}Enum 41 {% endif %} 42 {% endfor %} 43 {% for command in join_arrays(domain, ["commands", "events"]) %} 44 {% for param in join_arrays(command, ["parameters", "returns"]) %} 45 {% if ("enum" in param) and protocol.is_exported(domain.domain, command.name + "." + param.name) %} 46 47namespace {{command.name | to_title_case}} { 48namespace {{param.name | to_title_case}}Enum { 49 {% for literal in param.enum %} 50{{config.exported.export_macro}} extern const char* {{ literal | dash_to_camelcase}}; 51 {% endfor %} 52} // {{param.name | to_title_case}}Enum 53} // {{command.name | to_title_case }} 54 {% endif %} 55 {% endfor %} 56 {% endfor %} 57 58// ------------- Types. 59 {% for type in domain.types %} 60 {% if not (type.type == "object") or not ("properties" in type) or not protocol.is_exported(domain.domain, type.id) %}{% continue %}{% endif %} 61 62class {{config.exported.export_macro}} {{type.id}} : public Exported { 63public: 64 static std::unique_ptr<protocol::{{domain.domain}}::API::{{type.id}}> fromJSONString(const {{config.exported.string_in}}& json); 65 static std::unique_ptr<protocol::{{domain.domain}}::API::{{type.id}}> fromBinary(const uint8_t* data, size_t length); 66}; 67 {% endfor %} 68 69} // namespace API 70} // namespace {{domain.domain}} 71{% for namespace in config.protocol.namespace %} 72} // namespace {{namespace}} 73{% endfor %} 74 75#endif // !defined({{"_".join(config.protocol.namespace)}}_{{domain.domain}}_api_h) 76