diff options
author | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2013-03-04 11:30:34 +0000 |
---|---|---|
committer | Przemyslaw Szczepaniak <pszczepaniak@google.com> | 2013-03-04 11:30:34 +0000 |
commit | 5bf56ba7027cd5f22ff52d0138893f7a585135fb (patch) | |
tree | 19e17fc79b8873e66f211276d4dd169c480cede1 /src/include/fst/script/fst-class.h | |
parent | 3da1eb108d36da35333b2d655202791af854996b (diff) | |
parent | 5b6dc79427b8f7eeb6a7ff68034ab8548ce670ea (diff) | |
download | openfst-5bf56ba7027cd5f22ff52d0138893f7a585135fb.tar.gz |
Merge remote-tracking branch 'goog/ics-ub-google-tts' into jb-mr2-devandroid-sdk-4.4.2_r1.0.1android-sdk-4.4.2_r1android-cts-4.4_r4android-cts-4.4_r1android-4.4w_r1android-4.4_r1.2.0.1android-4.4_r1.2android-4.4_r1.1.0.1android-4.4_r1.1android-4.4_r1.0.1android-4.4_r1android-4.4_r0.9android-4.4_r0.8android-4.4_r0.7android-4.4.4_r2.0.1android-4.4.4_r2android-4.4.4_r1.0.1android-4.4.4_r1android-4.4.3_r1.1.0.1android-4.4.3_r1.1android-4.4.3_r1.0.1android-4.4.3_r1android-4.4.2_r2.0.1android-4.4.2_r2android-4.4.2_r1.0.1android-4.4.2_r1android-4.4.1_r1.0.1android-4.4.1_r1android-4.3_r3.1android-4.3_r3android-4.3_r2.3android-4.3_r2.2android-4.3_r2.1android-4.3_r2android-4.3_r1.1android-4.3_r1android-4.3_r0.9.1android-4.3_r0.9android-4.3.1_r1tools_r22.2kitkat-wearkitkat-releasekitkat-mr2.2-releasekitkat-mr2.1-releasekitkat-mr2-releasekitkat-mr1.1-releasekitkat-mr1-releasekitkat-devkitkat-cts-releasekitkat-cts-devjb-mr2.0.0-releasejb-mr2.0-releasejb-mr2-releasejb-mr2-devidea133-weekly-releaseidea133
Diffstat (limited to 'src/include/fst/script/fst-class.h')
-rw-r--r-- | src/include/fst/script/fst-class.h | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/include/fst/script/fst-class.h b/src/include/fst/script/fst-class.h index a820c1c..fe2cf53 100644 --- a/src/include/fst/script/fst-class.h +++ b/src/include/fst/script/fst-class.h @@ -52,8 +52,8 @@ class FstClassBase { virtual const string &WeightType() const = 0; virtual const SymbolTable *InputSymbols() const = 0; virtual const SymbolTable *OutputSymbols() const = 0; - virtual void Write(const string& fname) const = 0; - virtual void Write(ostream &ostr, const FstWriteOptions &opts) const = 0; + virtual bool Write(const string& fname) const = 0; + virtual bool Write(ostream &ostr, const FstWriteOptions &opts) const = 0; virtual uint64 Properties(uint64 mask, bool test) const = 0; virtual ~FstClassBase() { } }; @@ -82,6 +82,8 @@ class FstClassImpl : public FstClassImplBase { bool should_own = false) : impl_(should_own ? impl : impl->Copy()) { } + explicit FstClassImpl(const Fst<Arc> &impl) : impl_(impl.Copy()) { } + virtual const string &ArcType() const { return Arc::Type(); } @@ -112,12 +114,12 @@ class FstClassImpl : public FstClassImplBase { static_cast<MutableFst<Arc> *>(impl_)->SetOutputSymbols(os); } - virtual void Write(const string &fname) const { - impl_->Write(fname); + virtual bool Write(const string &fname) const { + return impl_->Write(fname); } - virtual void Write(ostream &ostr, const FstWriteOptions &opts) const { - impl_->Write(ostr, opts); + virtual bool Write(ostream &ostr, const FstWriteOptions &opts) const { + return impl_->Write(ostr, opts); } virtual uint64 Properties(uint64 mask, bool test) const { @@ -166,10 +168,10 @@ class FstClass : public FstClassBase { } template<class Arc> - explicit FstClass(Fst<Arc> *fst) : impl_(new FstClassImpl<Arc>(fst)) { + explicit FstClass(const Fst<Arc> &fst) : impl_(new FstClassImpl<Arc>(fst)) { } - explicit FstClass(const FstClass &other) : impl_(other.impl_->Copy()) { } + FstClass(const FstClass &other) : impl_(other.impl_->Copy()) { } FstClass &operator=(const FstClass &other) { delete impl_; @@ -201,12 +203,12 @@ class FstClass : public FstClassBase { return impl_->WeightType(); } - virtual void Write(const string &fname) const { - impl_->Write(fname); + virtual bool Write(const string &fname) const { + return impl_->Write(fname); } - virtual void Write(ostream &ostr, const FstWriteOptions &opts) const { - impl_->Write(ostr, opts); + virtual bool Write(ostream &ostr, const FstWriteOptions &opts) const { + return impl_->Write(ostr, opts); } virtual uint64 Properties(uint64 mask, bool test) const { @@ -253,7 +255,7 @@ class FstClass : public FstClassBase { if (!u) { return 0; } else { - FstClassT *r = new FstClassT(u); + FstClassT *r = new FstClassT(*u); delete u; return r; } @@ -276,7 +278,7 @@ class FstClass : public FstClassBase { class MutableFstClass : public FstClass { public: template<class Arc> - explicit MutableFstClass(MutableFst<Arc> *fst) : + explicit MutableFstClass(const MutableFst<Arc> &fst) : FstClass(fst) { } template<class Arc> @@ -294,18 +296,18 @@ class MutableFstClass : public FstClass { if (!mfst) { return 0; } else { - MutableFstClass *retval = new MutableFstClass(mfst); + MutableFstClass *retval = new MutableFstClass(*mfst); delete mfst; return retval; } } - virtual void Write(const string &fname) const { - GetImpl()->Write(fname); + virtual bool Write(const string &fname) const { + return GetImpl()->Write(fname); } - virtual void Write(ostream &ostr, const FstWriteOptions &opts) const { - GetImpl()->Write(ostr, opts); + virtual bool Write(ostream &ostr, const FstWriteOptions &opts) const { + return GetImpl()->Write(ostr, opts); } static MutableFstClass *Read(const string &fname, bool convert = false); @@ -344,7 +346,7 @@ class VectorFstClass : public MutableFstClass { explicit VectorFstClass(const string &arc_type); template<class Arc> - explicit VectorFstClass(VectorFst<Arc> *fst) : + explicit VectorFstClass(const VectorFst<Arc> &fst) : MutableFstClass(fst) { } template<class Arc> @@ -354,7 +356,7 @@ class VectorFstClass : public MutableFstClass { if (!vfst) { return 0; } else { - VectorFstClass *retval = new VectorFstClass(vfst); + VectorFstClass *retval = new VectorFstClass(*vfst); delete vfst; return retval; } |