Loading...
Searching...
No Matches
ConversionChain.hpp
/*
* Open Chinese Convert
*
* Copyright 2010-2014 Carbo Kuo <byvoid@byvoid.com>
*
* 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.
*/
#pragma once
#include <list>
#include "Common.hpp"
#include "Conversion.hpp"
namespace opencc {
class OPENCC_EXPORT ConversionChain {
public:
ConversionChain(const std::list<ConversionPtr> _conversions);
SegmentsPtr Convert(const SegmentsPtr& input) const;
void AppendConvertedSegment(const char* segment, std::string* output) const;
void AppendConvertedSegment(std::string_view segment,
std::string* output) const;
std::vector<SegmentsPtr> ConvertWithTrace(const SegmentsPtr& input) const;
const std::list<ConversionPtr> GetConversions() const { return conversions; }
private:
const std::list<ConversionPtr> conversions;
};
} // namespace opencc
opencc::ConversionChain::ConversionChain
ConversionChain(const std::list< ConversionPtr > _conversions)
Constructs a chain from an ordered list of conversions.
Definition ConversionChain.cpp:27
opencc::ConversionChain::Convert
SegmentsPtr Convert(const SegmentsPtr &input) const
Passes input through every conversion in the chain sequentially and returns the final Segments.
Definition ConversionChain.cpp:30
opencc::ConversionChain::AppendConvertedSegment
void AppendConvertedSegment(const char *segment, std::string *output) const
Converts the null-terminated segment through all conversions and appends the result to output.
Definition ConversionChain.cpp:38
opencc::ConversionChain::ConvertWithTrace
std::vector< SegmentsPtr > ConvertWithTrace(const SegmentsPtr &input) const
Converts input through the chain and records every intermediate Segments after each conversion stage.
Definition ConversionChain.cpp:94
opencc::ConversionChain::GetConversions
const std::list< ConversionPtr > GetConversions() const
Returns the list of conversions in application order.
Definition ConversionChain.hpp:76