1af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// Copyright (C) 2012 The Libphonenumber Authors
2af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com//
3af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// Licensed under the Apache License, Version 2.0 (the "License");
4af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// you may not use this file except in compliance with the License.
5af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// You may obtain a copy of the License at
6af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com//
7af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// http://www.apache.org/licenses/LICENSE-2.0
8af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com//
9af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// Unless required by applicable law or agreed to in writing, software
10af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// distributed under the License is distributed on an "AS IS" BASIS,
11af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// See the License for the specific language governing permissions and
13af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// limitations under the License.
14af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com
15af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// We need this because when ICU is built without std::string support,
16af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// UnicodeString::toUTF8String() is not available. The alternative,
17af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// UnicodeString::toUTF8(), requires an implementation of a string byte sink.
18af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com// See unicode/unistr.h and unicode/bytestream.h in ICU for more details.
19af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com
20af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com#include <string>
21af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com
22af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com#include <unicode/unistr.h>
23af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com
24af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.comnamespace i18n {
25af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.comnamespace phonenumbers {
26af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com
27af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.comclass StringByteSink : public icu::ByteSink {
28af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com public:
29af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com  // Constructs a ByteSink that will append bytes to the dest string.
30af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com  explicit StringByteSink(std::string* dest);
31af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com  virtual ~StringByteSink();
32af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com
33af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com  virtual void Append(const char* data, int32_t n);
34af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com
35af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com private:
36af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com  std::string* const dest_;
37af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com};
38af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com
39af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com}  // namespace phonenumbers
40af3adc4377ce5f9eb45ccaf75bb21795701211caphilip.liard@gmail.com}  // namespace i18n
41