blob: 1803b9119d840d4398d47d72b867e763a673edd9 [file] [edit]
// Copyright 2026 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#include "enum_example/basic_enum.h"
#include "pw_enum/to_string.h"
#include "pw_log/log.h"
#include "pw_log/tokenized_args.h"
namespace my::nested::pkg {
const char* HandleEnum(MyEnum value) {
// Log the enum as a string or token, depending on the logging backend.
PW_LOG_INFO("The enum value is: " MY_NESTED_PKG_MY_ENUM, PW_LOG_ENUM(value));
switch (value) {
case MyEnum::kAlpha:
// Handle case kAlpha
break;
case MyEnum::kBeta:
// Handle case kBeta
break;
}
// The const char* string version of the enum is always available.
return pw::EnumToString(value);
}
} // namespace my::nested::pkg