summaryrefslogtreecommitdiff
path: root/chromium/components/arc/arc_instance_mode.cc
blob: de0439afd684a0353c950e9fb02f61304df30fcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/arc/arc_instance_mode.h"

#include <string>

#include "base/logging.h"

namespace arc {
namespace {

std::string ArcInstanceModeToString(ArcInstanceMode mode) {
#define MAP_MODE(name)        \
  case ArcInstanceMode::name: \
    return #name

  switch (mode) {
    MAP_MODE(MINI_INSTANCE);
    MAP_MODE(FULL_INSTANCE);
  }
#undef MAP_MODE

  // Some compilers report an error even if all values of an enum-class are
  // covered exhaustively in a switch statement.
  NOTREACHED() << "Invalid value " << static_cast<int>(mode);
  return std::string();
}

}  // namespace

std::ostream& operator<<(std::ostream& os, ArcInstanceMode mode) {
  return os << ArcInstanceModeToString(mode);
}

std::ostream& operator<<(std::ostream& os,
                         base::Optional<ArcInstanceMode> mode) {
  return os << (mode.has_value() ? ArcInstanceModeToString(mode.value())
                                 : "(nullopt)");
}

}  // namespace arc