training/name2char.cpp File Reference

#include "name2char.h"
#include "matchdefs.h"
#include "danerror.h"
#include <string.h>

Go to the source code of this file.

Defines

Functions

Variables


Define Documentation

#define ILLEGALCHARNAME   6001

Note:
File: name2char.cpp
Routines to convert between classes and class names.
Author:
Dan Johnson
Date:
Fri Feb 23 08:03:09 1990, DSJ, Created.
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.

Definition at line 26 of file name2char.cpp.

Referenced by NameToChar().


Function Documentation

void CharToName ( CLASS_ID  Char,
char  CharName[] 
)

Converts the specified ascii character to a character name.

Parameters:
Char Character to map to a character name
CharName String to copy character name into
Note:
Globals:
  • NameList = Lookup table for char to name mapping
This is convenient for representing characters which might have special meaning to operating system shells or other programs (e.g. "*?&><" etc.).
Date:
8/26/89, DSJ, Created.

Definition at line 144 of file name2char.cpp.

References NameList, and NULL.

00147 {
00148    int   i;
00149 
00150    /* look for character in table and return a copy of its name if found */
00151    for ( i = 0; NameList[i] != NULL; i++ )
00152       if ( Char == NameList[i][0] )
00153       {
00154          strcpy ( CharName, &NameList[i][1] );
00155          return;
00156       }
00157 
00158       /* if the character is not in the table, then use it as the name */
00159       CharName[0] = Char;
00160       CharName[1] = 0;
00161 
00162 }// CharToName

CLASS_ID NameToChar ( char  CharName[]  ) 

Converts the specified character name to an ascii character.

Exceptions:
ILLEGALCHARNAME. 

Parameters:
CharName Character name to convert to a character
Note:
Globals:
  • NameList = Lookup table for name to char mapping
Returns:
Ascii character that corresponds to the character name.
Date:
8/26/89, DSJ, Created.

Definition at line 112 of file name2char.cpp.

References DoError(), ILLEGALCHARNAME, NameList, and NULL.

Referenced by SetUpForFloat2Int(), WriteNormProtos(), and WriteProtos().

00114 {
00115    int   i;
00116 
00117    // look for name in table and return character if found
00118    for ( i = 0; NameList[i] != NULL; i++ )
00119       if ( strcmp (CharName, &NameList[i][1]) == 0)
00120          return (NameList[i][0]);
00121    if ( strlen (CharName) == 1 )
00122       return (CharName[0]);   //name is not in table but is a single character
00123    else  //illegal character
00124    {
00125       DoError (ILLEGALCHARNAME, "Illegal character name");
00126       return 0;
00127    }
00128 }// NameToChar


Variable Documentation

NameList [static]

Character ID (ascii code) to character name mapping.

Definition at line 35 of file name2char.cpp.

Referenced by CharToName(), and NameToChar().


Generated on Wed Feb 28 19:49:27 2007 for Tesseract by  doxygen 1.5.1