blob: 3a6e2e609f307bfb05d3ca42555dd3f5b7a28f29 [file] [log] [blame]
Steven Morelandb0057e72018-08-27 01:44:11 -07001/*
2 * Copyright (C) 2018, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <string>
20
21#include "aidl_language.h"
22
23// This is used to help generate code targetting C++ (the language) whether using the libbinder or
24// libbinder_ndk backend.
25
26namespace android {
27namespace aidl {
28namespace cpp {
29
30// These roughly correspond to the various class names in the C++ hierarchy:
31enum class ClassNames {
32 BASE, // Foo (not a real class, but useful in some circumstances).
33 CLIENT, // BpFoo
34 SERVER, // BnFoo
35 INTERFACE, // IFoo
36 DEFAULT_IMPL, // IFooDefault
Jiyong Park5b7e5322019-04-03 20:05:01 +090037 RAW, // (as shown in the file)
Steven Morelandb0057e72018-08-27 01:44:11 -070038};
39
40string ClassName(const AidlDefinedType& defined_type, ClassNames type);
41
42// Generate the relative path to a header file. If |use_os_sep| we'll use the
43// operating system specific path separator rather than C++'s expected '/' when
44// including headers.
45std::string HeaderFile(const AidlDefinedType& defined_type, ClassNames class_type,
46 bool use_os_sep = true);
47
48void EnterNamespace(CodeWriter& out, const AidlDefinedType& defined_type);
49void LeaveNamespace(CodeWriter& out, const AidlDefinedType& defined_type);
50
Steven Moreland3b1325f2018-09-20 14:45:40 -070051string BuildVarName(const AidlArgument& a);
52
Steven Morelandb0057e72018-08-27 01:44:11 -070053} // namespace cpp
54} // namespace aidl
55} // namespace android