chromium/components/services/app_service/public/cpp/macros.h

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_SERVICES_APP_SERVICE_PUBLIC_CPP_MACROS_H_
#define COMPONENTS_SERVICES_APP_SERVICE_PUBLIC_CPP_MACROS_H_

#include <string>

#include "base/macros/concat.h"

namespace apps {

#define SET_OPTIONAL_VALUE(VALUE)

#define SET_ENUM_VALUE(VALUE, DEFAULT_VALUE)

#define GET_VALUE(VALUE)

#define IS_VALUE_CHANGED(VALUE)

#define GET_VALUE_WITH_FALLBACK(VALUE, FALLBACK_VALUE)

#define GET_VALUE_WITH_DEFAULT_VALUE(VALUE, DEFAULT_VALUE)

#define IS_VALUE_CHANGED_WITH_DEFAULT_VALUE(VALUE, DEFAULT_VALUE)

#define GET_VALUE_WITH_CHECK_AND_DEFAULT_RETURN(VALUE, CHECK, DEFAULT_RETURN)

#define IS_VALUE_CHANGED_WITH_CHECK(VALUE, CHECK)

#define RETURN_OPTIONAL_VALUE_CHANGED(VALUE)

#define PRINT_OPTIONAL_BOOL(VALUE)

#define IS_VECTOR_VALUE_EQUAL(VALUE)

// Macros for enum

#define ARC_COUNT_(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
                   _14, _15, _16, N, ...)
#define ARG_COUNT(...)

// Go through all items in enum to generate code for each element.
#define DOARG1(FUNC, CLASSNAME, ELEM)
#define DOARG2(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG3(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG4(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG5(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG6(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG7(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG8(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG9(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG10(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG11(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG12(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG13(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG14(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG15(FUNC, CLASSNAME, ELEM1, ...)
#define DOARG16(FUNC, CLASSNAME, ELEM1, ...)

#define FOREACH_(FUNC, CLASSNAME, ...)

#define GET_ELEM(N, ...)
#define GET_ELEM1(_1, ...)
#define GET_ELEM2(_1, _2, ...)
#define GET_ELEM3(_1, _2, _3, ...)
#define GET_ELEM4(_1, _2, _3, _4, ...)
#define GET_ELEM5(_1, _2, _3, _4, _5, ...)
#define GET_ELEM6(_1, _2, _3, _4, _5, _6, ...)
#define GET_ELEM7(_1, _2, _3, _4, _5, _6, _7, ...)
#define GET_ELEM8(_1, _2, _3, _4, _5, _6, _7, _8, ...)
#define GET_ELEM9(_1, _2, _3, _4, _5, _6, _7, _8, _9, ...)
#define GET_ELEM10(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, ...)
#define GET_ELEM11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, ...)
#define GET_ELEM12(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, ...)
#define GET_ELEM13(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
                   ...)
#define GET_ELEM14(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
                   _14, ...)
#define GET_ELEM15(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
                   _14, _15, ...)
#define GET_ELEM16(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
                   _14, _15, _16, ...)

// Get last argument.
#define GET_LAST(...)

// Macros for enum definitions
#define ELEM(CLASSNAME, E)

// Macro to generate enum `CLASSNAME` for elements, and the definition for the
// `EnumToString`, e.g.:
//   enum class ClassName {
//     kUnknown,
//     kElement1,
//     kElement2,
//     kElement3,
//     kMaxValue = kElement3,
//  };
//  COMPONENT_EXPORT(APP_TYPES)
//  std::string EnumToString(ClassName input);
//
// Modify ARC_COUNT, GET_ELEMXX and DOARGXX to support more elements.
#define ENUM(CLASSNAME, ...)

#define ENUM_FOR_COMPONENT(COMPONENT, CLASSNAME, ...)

// Macros to print enum
#define PRINT_CLASSNAME_AND_ELEM(CLASSNAME, ELEM)

#define PRINT_ELEM(CLASSNAME, ELEM)

// Macro to generate the function `EnumToString` to print the enum `CLASSNAME`
// elements, e.g.:
//   std::string EnumToString(ClassName input) {
//     switch (input) {
//       case ClassName::kElement1:
//         return "ClassName::kElement1";
//       case ClassName::kElement2:
//         return "ClassName::kElement2";
//       case ClassName::kElement3:
//         return "ClassName::kElement1";
//    }
//  }
//
// Modify ARC_COUNT, GET_ELEMXX and DOARGXX to support more elements.
#define APP_ENUM_TO_STRING(CLASSNAME, ...)

}  // namespace apps

#endif  // COMPONENTS_SERVICES_APP_SERVICE_PUBLIC_CPP_MACROS_H_