aboutsummaryrefslogtreecommitdiff
path: root/cpp/src/address_problem.cc
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-06-20 14:52:47 +0100
committerTorne (Richard Coles) <torne@google.com>2014-06-20 14:52:47 +0100
commitb8347ad8ead685b8afe0ff329ae047f17c7b817c (patch)
tree6b0965940e7059bb96891e00e9fe8da7a8383c33 /cpp/src/address_problem.cc
parentbe7edd6e608768a423c246f9f13c632349a31c5f (diff)
parentd56141c71497da3224256e3d007f4ab1b8bf4ed4 (diff)
downloadsrc-b8347ad8ead685b8afe0ff329ae047f17c7b817c.tar.gz
Merge from Chromium at DEPS revision 278205
This commit was generated by merge_to_master.py. Change-Id: I54dfe87045260dd68161b9e69e4e6d099ec06849
Diffstat (limited to 'cpp/src/address_problem.cc')
-rw-r--r--cpp/src/address_problem.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/cpp/src/address_problem.cc b/cpp/src/address_problem.cc
new file mode 100644
index 0000000..e6cf446
--- /dev/null
+++ b/cpp/src/address_problem.cc
@@ -0,0 +1,44 @@
+// Copyright (C) 2014 Google Inc.
+//
+// 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
+//
+// http://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 <libaddressinput/address_problem.h>
+
+#include <cstddef>
+#include <ostream>
+
+#include <libaddressinput/util/basictypes.h>
+
+using i18n::addressinput::AddressProblem;
+using i18n::addressinput::UNEXPECTED_FIELD;
+using i18n::addressinput::USES_P_O_BOX;
+
+std::ostream& operator<<(std::ostream& o, AddressProblem problem) {
+ static const char* const kProblemNames[] = {
+ "UNEXPECTED_FIELD",
+ "MISSING_REQUIRED_FIELD",
+ "UNKNOWN_VALUE",
+ "INVALID_FORMAT",
+ "MISMATCHING_VALUE",
+ "USES_P_O_BOX"
+ };
+ COMPILE_ASSERT(UNEXPECTED_FIELD == 0, bad_base);
+ COMPILE_ASSERT(USES_P_O_BOX == arraysize(kProblemNames) - 1, bad_length);
+
+ if (problem < 0 || static_cast<size_t>(problem) >= arraysize(kProblemNames)) {
+ o << "[INVALID ENUM VALUE " << static_cast<int>(problem) << "]";
+ } else {
+ o << kProblemNames[problem];
+ }
+ return o;
+}