Minor c/c++ codegen update
1, Moved "#include <string>" from exported header to test flag provider
header file.
2, For production target and read only flags, the generated c
api should just return default value instead of calling into c++ api
3, Remove using namespace server_configurable_flags from header, instead
of just having the namespace to be spelled out in each api call. Having
using namespace xxx in header is not a c++ best practice.
4, Replace #ifdef #def #endif with #pragma once
Bug: b/279483801
Test: atest aconfig.test
Change-Id: I3e55a7b14301f3de419795467f33e2dc889d371e
diff --git a/tools/aconfig/templates/c_source_file.template b/tools/aconfig/templates/c_source_file.template
index 3d2482d..384221d 100644
--- a/tools/aconfig/templates/c_source_file.template
+++ b/tools/aconfig/templates/c_source_file.template
@@ -3,7 +3,15 @@
{{ for item in class_elements}}
bool {header}_{item.flag_name}() \{
+ {{ if for_test }}
return {cpp_namespace}::{item.flag_name}();
+ {{ -else- }}
+ {{ if not item.readwrite- }}
+ return {item.default_value};
+ {{ -else- }}
+ return {cpp_namespace}::{item.flag_name}();
+ {{ -endif }}
+ {{ -endif }}
}
{{ if for_test }}