Classes | Namespaces | Defines | Functions

openfst-1.2.6/src/include/fst/util.h File Reference

util.h More...

#include <tr1/unordered_map>
#include <tr1/unordered_set>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <fst/compat.h>
#include <fst/types.h>
#include <iostream>
#include <fstream>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  fst::CompactSet< Key, NoKey >

Namespaces

namespace  fst
 

For optional argument declarations.


Defines

#define READ_POD_TYPE(T)
 Fixed size, contiguous memory read.
#define READ_STL_SEQ_TYPE(C)
 STL sequence container.
#define READ_STL_ASSOC_TYPE(C)
 STL associative container.
#define WRITE_POD_TYPE(T)
 Fixed size, contiguous memory write.
#define WRITE_STL_SEQ_TYPE(C)
 STL sequence container.
#define WRITE_STL_ASSOC_TYPE(C)
 STL associative container.

Functions

template<typename T >
istream & fst::ReadType (istream &strm, T *t)
 Read some types from an input stream.
 fst::READ_POD_TYPE (bool)
 fst::READ_POD_TYPE (char)
 fst::READ_POD_TYPE (signed char)
 fst::READ_POD_TYPE (unsigned char)
 fst::READ_POD_TYPE (short)
 fst::READ_POD_TYPE (int)
 fst::READ_POD_TYPE (long)
 fst::READ_POD_TYPE (unsigned long long)
 fst::READ_POD_TYPE (float)
 fst::READ_POD_TYPE (double)
istream & fst::ReadType (istream &strm, string *s)
 String case.
template<typename S , typename T >
istream & fst::ReadType (istream &strm, pair< S, T > *p)
 Pair case.
template<typename S , typename T >
istream & fst::ReadType (istream &strm, pair< const S, T > *p)
template<typename C >
void fst::StlReserve (C *c, int64 n)
 General case - no-op.
template<typename S , typename T >
void fst::StlReserve (vector< S, T > *c, int64 n)
 Specialization for vectors.
 fst::READ_STL_SEQ_TYPE (vector)
 fst::READ_STL_SEQ_TYPE (list)
 fst::READ_STL_ASSOC_TYPE (set)
 fst::READ_STL_ASSOC_TYPE (unordered_set)
 fst::READ_STL_ASSOC_TYPE (map)
 fst::READ_STL_ASSOC_TYPE (unordered_map)
template<typename T >
ostream & fst::WriteType (ostream &strm, const T t)
 Write some types to an output stream.
 fst::WRITE_POD_TYPE (bool)
 fst::WRITE_POD_TYPE (char)
 fst::WRITE_POD_TYPE (signed char)
 fst::WRITE_POD_TYPE (unsigned char)
 fst::WRITE_POD_TYPE (short)
 fst::WRITE_POD_TYPE (int)
 fst::WRITE_POD_TYPE (long)
 fst::WRITE_POD_TYPE (unsigned long long)
 fst::WRITE_POD_TYPE (float)
 fst::WRITE_POD_TYPE (double)
ostream & fst::WriteType (ostream &strm, const string &s)
 String case.
template<typename S , typename T >
ostream & fst::WriteType (ostream &strm, const pair< S, T > &p)
 Pair case.
 fst::WRITE_STL_SEQ_TYPE (vector)
 fst::WRITE_STL_SEQ_TYPE (list)
 fst::WRITE_STL_ASSOC_TYPE (set)
 fst::WRITE_STL_ASSOC_TYPE (unordered_set)
 fst::WRITE_STL_ASSOC_TYPE (map)
 fst::WRITE_STL_ASSOC_TYPE (unordered_map)
int64 fst::StrToInt64 (const string &s, const string &src, size_t nline, bool allow_negative)
 Utilities for converting between int64 or Weight and string.
template<typename Weight >
Weight fst::StrToWeight (const string &s, const string &src, size_t nline)
void fst::Int64ToStr (int64 n, string *s)
template<typename Weight >
void fst::WeightToStr (Weight w, string *s)
template<typename Label >
void fst::ReadLabelPairs (const string &filename, vector< pair< Label, Label > > *pairs, bool allow_negative=false)
 Utilities for reading/writing label pairs.
template<typename Label >
void fst::WriteLabelPairs (const string &filename, const vector< pair< Label, Label > > &pairs)
void fst::ConvertToLegalCSymbol (string *s)
 Utilities for converting a type name to a legal C symbol.

Detailed Description

util.h

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.

Copyright 2005-2010 Google, Inc. Author: riley@google.com (Michael Riley)

FST utility inline definitions.

Definition in file util.h.


Define Documentation

#define READ_POD_TYPE (   T  ) 
Value:
inline istream &ReadType(istream &strm, T *t) {             \
  return strm.read(reinterpret_cast<char *>(t), sizeof(T)); \
}

Fixed size, contiguous memory read.

Definition at line 59 of file util.h.

#define READ_STL_ASSOC_TYPE (   C  ) 
Value:
template <typename S, typename T, typename U>            \
inline istream &ReadType(istream &strm, C<S, T, U> *c) { \
  c->clear();                                            \
  int64 n = 0;                                           \
  strm.read(reinterpret_cast<char *>(&n), sizeof(n));    \
  for (ssize_t i = 0; i < n; ++i) {                      \
    typename C<S, T, U>::value_type value;               \
    ReadType(strm, &value);                              \
    c->insert(value);                                    \
  }                                                      \
  return strm;                                           \
}

STL associative container.

Definition at line 137 of file util.h.

#define READ_STL_SEQ_TYPE (   C  ) 
Value:
template <typename S, typename T>                        \
inline istream &ReadType(istream &strm, C<S, T> *c) {    \
  c->clear();                                            \
  int64 n = 0;                                           \
  strm.read(reinterpret_cast<char *>(&n), sizeof(n));    \
  StlReserve(c, n);                                      \
  for (ssize_t i = 0; i < n; ++i) {                      \
    typename C<S, T>::value_type value;                  \
    ReadType(strm, &value);                              \
    c->insert(c->end(), value);                          \
  }                                                      \
  return strm;                                           \
}

STL sequence container.

Definition at line 118 of file util.h.

#define WRITE_POD_TYPE (   T  ) 
Value:
inline ostream &WriteType(ostream &strm, const T t) {               \
  return strm.write(reinterpret_cast<const char *>(&t), sizeof(T)); \
}

Fixed size, contiguous memory write.

Definition at line 166 of file util.h.

#define WRITE_STL_ASSOC_TYPE (   C  ) 
Value:
template <typename S, typename T, typename U>                                \
inline ostream &WriteType(ostream &strm, const C<S, T, U> &c) {              \
  int64 n = c.size();                                                        \
  strm.write(reinterpret_cast<char *>(&n), sizeof(n));                       \
  for (typename C<S, T, U>::const_iterator it = c.begin();                   \
       it != c.end(); ++it)                                                  \
     WriteType(strm, *it);                                                   \
  return strm;                                                               \
}

STL associative container.

Definition at line 217 of file util.h.

#define WRITE_STL_SEQ_TYPE (   C  ) 
Value:
template <typename S, typename T>                                            \
inline ostream &WriteType(ostream &strm, const C<S, T> &c) {                 \
  int64 n = c.size();                                                        \
  strm.write(reinterpret_cast<char *>(&n), sizeof(n));                       \
  for (typename C<S, T>::const_iterator it = c.begin();                      \
       it != c.end(); ++it)                                                  \
     WriteType(strm, *it);                                                   \
  return strm;                                                               \
}

STL sequence container.

Definition at line 202 of file util.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines