1 // Copyright (C) 2013 Google Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include <libaddressinput/address_problem.h> 16 17 #include <ostream> 18 #include <string> 19 20 namespace i18n { 21 namespace addressinput { 22 23 AddressProblem::AddressProblem(AddressField field, 24 Type type, 25 int description_id) 26 : field(field), type(type), description_id(description_id) {} 27 28 AddressProblem::~AddressProblem() {} 29 30 std::ostream& operator<<(std::ostream& o, AddressProblem::Type problem_type) { 31 switch (problem_type) { 32 case AddressProblem::MISSING_REQUIRED_FIELD: 33 o << "MISSING_REQUIRED_FIELD"; 34 break; 35 case AddressProblem::UNKNOWN_VALUE: 36 o << "UNKNOWN_VALUE"; 37 break; 38 case AddressProblem::UNRECOGNIZED_FORMAT: 39 o << "UNRECOGNIZED_FORMAT"; 40 break; 41 case AddressProblem::MISMATCHING_VALUE: 42 o << "MISMATCHING_VALUE"; 43 break; 44 default : 45 o << "[INVALID]"; 46 break; 47 } 48 return o; 49 } 50 51 std::ostream& operator<<(std::ostream& o, const AddressProblem& problem) { 52 o << "[" << problem.field << ", " 53 << problem.type << ", \"" 54 << problem.description_id << "\"]"; 55 return o; 56 } 57 58 } // namespace addressinput 59 } // namespace i18n 60