Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends
converter_rep Class Reference

#include <converter.hpp>

Inheritance diagram for converter_rep:
Inheritance graph
[legend]
Collaboration diagram for converter_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 converter_rep (string from2, string to2)
bool has_value (hashtree< char, string > node)

Public Attributes

string res_name

Private Member Functions

void match (string &str, int &index)
void load ()

Private Attributes

hashtree< char, stringht
string output
string nil_string
string from
string to
bool copy_unmatched

Friends

class converter
string flush (converter c)
string apply (converter c, string str)
void operator<< (converter c, string str)

Detailed Description

Definition at line 29 of file converter.hpp.


Constructor & Destructor Documentation

converter_rep::converter_rep ( string  from2,
string  to2 
) [inline]

Definition at line 37 of file converter.hpp.

                                                 : 
    rep<converter>(from2*"-"*to2), ht(), output(), 
    nil_string(), from(from2), to(to2), copy_unmatched(true) { load(); }

Here is the call graph for this function:


Member Function Documentation

bool converter_rep::has_value ( hashtree< char, string node) [inline]

Definition at line 64 of file converter.cpp.

                                                   {
  return node->label != nil_string;
}

Here is the caller graph for this function:

void converter_rep::load ( ) [private]

Definition at line 102 of file converter.cpp.

                     {
  // to handle each case individually seems unelegant, but there is simply more
  // to be done here than just loading a file.
  // cout << "TeXmacs] load converter " << from << " -> " << to << "\n";
  if ( from=="Cork" && to=="UTF-8" ) {
    hashtree<char,string> dic;
    hashtree_from_dictionary (dic,"corktounicode", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"cork-unicode-oneway", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"tmuniversaltounicode", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"symbol-unicode-oneway", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"symbol-unicode-math", BIT2BIT, UTF8, false);
    ht = dic;
  }
  else if ( from=="UTF-8" && to=="Cork") {
    hashtree<char,string> dic;
    hashtree_from_dictionary (dic,"corktounicode", UTF8, BIT2BIT, true);
    hashtree_from_dictionary (dic,"unicode-cork-oneway", UTF8, BIT2BIT, false);
    hashtree_from_dictionary (dic,"tmuniversaltounicode", UTF8, BIT2BIT, true);
    hashtree_from_dictionary (dic,"unicode-symbol-oneway", UTF8, BIT2BIT, true);
    ht = dic;
  }
  else if ( from=="UTF-8" && to=="HTML") {
    hashtree<char,string> dic;
    hashtree_from_dictionary (dic, "HTMLlat1"   , CHAR_ENTITY, ENTITY_NAME, true);
    hashtree_from_dictionary (dic, "HTMLspecial", CHAR_ENTITY, ENTITY_NAME, true);
    hashtree_from_dictionary (dic, "HTMLsymbol" , CHAR_ENTITY, ENTITY_NAME, true);
    ht = dic;
  } else if ( from=="T2A" && to=="UTF-8" ) {
    hashtree<char,string> dic;
    hashtree_from_dictionary (dic,"corktounicode", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"cork-unicode-oneway", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"tmuniversaltounicode", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"symbol-unicode-oneway", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"symbol-unicode-math", BIT2BIT, UTF8, false);
    hashtree_from_dictionary (dic,"t2atounicode", BIT2BIT, UTF8, false);
    ht = dic;
  }  
}

Here is the call graph for this function:

Here is the caller graph for this function:

void converter_rep::match ( string str,
int &  index 
) [inline, private]

Definition at line 69 of file converter.cpp.

                                             {
  int forward = index;
  int last_match = -1;
  string value("");
  bool done = false;
  hashtree<char,string> node = ht;
  //cout << "[";
  while (!done && forward < N(str)) {
    if (node->contains (str[forward])) {
      node = node(str[forward]);
      //printf("->%x",str[forward]);
      if (has_value(node)) {
        last_match = forward;
        value = node->label;
      }
      forward++;
    }
    else done = true;
  }
  if (last_match==-1) {
    if (copy_unmatched)
      output << string(str[index]);
    index++;
  }
  else {
    //printf(":");for(int i = 0; i < N(value);i++) printf("%x ",value[i]);
    output << value;
    index = last_match + 1;
  }
  //cout << "]";
}

Here is the call graph for this function:


Friends And Related Function Documentation

string apply ( converter  c,
string  str 
) [friend]

Definition at line 33 of file converter.cpp.

                                {
  c->output = string();
  c << str;
  return flush(c);
}
friend class converter [friend]

Definition at line 43 of file converter.hpp.

string flush ( converter  c) [friend]

Definition at line 40 of file converter.cpp.

                    {
  string result = c->output;
  c->output = string();
  return result;
}
void operator<< ( converter  c,
string  str 
) [friend]

Definition at line 26 of file converter.cpp.

                                      {
  int index = 0;
  while (index < N(str))
    c->match(str, index);
}

Member Data Documentation

Definition at line 32 of file converter.hpp.

Definition at line 31 of file converter.hpp.

Definition at line 30 of file converter.hpp.

Definition at line 31 of file converter.hpp.

Definition at line 31 of file converter.hpp.

string rep< converter >::res_name [inherited]

Definition at line 17 of file resource.hpp.

Definition at line 31 of file converter.hpp.


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