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/cpp_test_flag_provider.template b/tools/aconfig/templates/cpp_test_flag_provider.template
index afa56cf..03f10a5 100644
--- a/tools/aconfig/templates/cpp_test_flag_provider.template
+++ b/tools/aconfig/templates/cpp_test_flag_provider.template
@@ -1,13 +1,13 @@
-#ifndef {header}_flag_provider_HEADER_H
-#define {header}_flag_provider_HEADER_H
+#pragma once
+
#include "{header}.h"
{{ if readwrite }}
#include <server_configurable_flags/get_flags.h>
-using namespace server_configurable_flags;
{{ endif }}
#include <unordered_map>
+#include <string>
namespace {cpp_namespace} \{
class flag_provider : public flag_provider_interface \{
@@ -26,7 +26,7 @@
return it->second;
} else \{
{{ if item.readwrite- }}
- return GetServerConfigurableFlag(
+ return server_configurable_flags::GetServerConfigurableFlag(
"{item.device_config_namespace}",
"{item.device_config_flag}",
"{item.default_value}") == "true";
@@ -46,4 +46,3 @@
}
};
}
-#endif