Loading...
Searching...
No Matches
opencc::Converter Class Referenceabstract
OpenCC C++ Comprehensive API

Abstract base for full-text converters. More...

`#include <src/Converter.hpp>`

Inheritance diagram for opencc::Converter:

## Public Member Functions

virtual std::string | Convert (std::string_view text) const =0
| Converts `text` and returns the result.
virtual ConversionInspectionResult | Inspect (std::string_view text) const =0
| Converts `text` and returns a detailed inspection result that includes the initial segmentation, per-stage intermediate segments, and final output.
virtual SegmentationPtr | GetSegmentation () const =0
| Returns the segmentation used by this converter, or `nullptr` if the converter has no single segmentation (e.g.
virtual ConversionChainPtr | GetConversionChain () const =0
| Returns the conversion chain used by this converter, or `nullptr` if the converter has no single chain (e.g.

## Detailed Description

Abstract base for full-text converters.

A `Converter` accepts a complete UTF-8 string and returns the converted result. Internally it coordinates `Segmentation` (splitting text into words) and a `ConversionChain` (applying one or more dictionaries to each segment). Concrete implementations:

- `SingleStageConverter` — one segmentation pass + one `ConversionChain`.
- `PipelineConverter` — passes text through a sequence of `Converter` stages in order, each with its own segmentation and chain.

Config-backed converters may additionally expose the main conversion chain via `GetConversionChain()` even when an internal normalization pre-pass is present.

## Member Function Documentation

## Convert()

virtual std::string opencc::Converter::Convert | ( | std::string_view | text | ) | const

pure virtual

Converts `text` and returns the result.

Parameters

  text | UTF-8 input; need not be null-terminated.

Implemented in opencc::ConfigBasedConverter, opencc::PipelineConverter, and opencc::SingleStageConverter.

## GetConversionChain()

virtual ConversionChainPtr opencc::Converter::GetConversionChain | ( |  | ) | const

pure virtual

Returns the conversion chain used by this converter, or `nullptr` if the converter has no single chain (e.g.

`PipelineConverter`).

Implemented in opencc::ConfigBasedConverter, opencc::PipelineConverter, and opencc::SingleStageConverter.

## GetSegmentation()

virtual SegmentationPtr opencc::Converter::GetSegmentation | ( |  | ) | const

pure virtual

Returns the segmentation used by this converter, or `nullptr` if the converter has no single segmentation (e.g.

`PipelineConverter`).

Implemented in opencc::ConfigBasedConverter, opencc::PipelineConverter, and opencc::SingleStageConverter.

## Inspect()

virtual ConversionInspectionResult opencc::Converter::Inspect | ( | std::string_view | text | ) | const

pure virtual

Converts `text` and returns a detailed inspection result that includes the initial segmentation, per-stage intermediate segments, and final output.

Intended for debugging and tooling rather than production conversion.

Implemented in opencc::ConfigBasedConverter, opencc::PipelineConverter, and opencc::SingleStageConverter.

The documentation for this class was generated from the following file:

- Converter.hpp