00001 // idep_aliasutil.h 00002 #ifndef INCLUDED_IDEP_ALIASUTIL 00003 #define INCLUDED_IDEP_ALIASUTIL 00004 00005 // This component defines 1 procedural utility class: 00006 // idep_AliasUtil: load an alias table with information read from a file 00007 00008 #include <iosfwd> 00009 class idep_AliasTable; 00010 00011 struct idep_AliasUtil { 00012 static int readAliases(idep_AliasTable *table, 00013 std::ostream& err, 00014 std::istream& in, 00015 const char *inputName); 00016 static int readAliases(idep_AliasTable *table, 00017 std::ostream& err, 00018 const char *file); 00019 // Read a description of aliases from a specified stream or file 00020 // and load this information into the specified alias table. 00021 // A contiguous sequence of non-whitespace characters is treated 00022 // as a name. The first name on a line represents the "to" name 00023 // the rest represent "from" names. If a single name appears on the 00024 // first line of a definition, the list is delimited by a blank line. 00025 // Any token beginning with a pound ('#') character will be ignored 00026 // as will all subsequent tokens until the end of the current line. 00027 // 00028 // # this is just a comment 00029 // a b c #d e f # b -> a; c -> a 00030 // d e # e -> d 00031 // f 00032 // g h # g -> f; h -> f 00033 // i # i -> f 00034 // 00035 // j k # k -> j 00036 // 00037 // A line can be continued by preceding the newline ('\n') 00038 // with a backslash ('\\') as a separate token. Note that neither 00039 // "a\" nor "\# comment" are treated as line continuation. 00040 // 00041 // l \ # line is continued 00042 // m n # m -> l; n -> l 00043 // 00044 // o 00045 // p q # p -> o; q -> o 00046 // \ # just a comment \ # 00047 // r # r -> o 00048 // 00049 // s t \ # t -> s 00050 // 00051 // u v # v -> u 00052 // 00053 // A backslash that is not followed by a newline is treated 00054 // as an identifier. A warning will be issued in such cases. 00055 // 00056 // \ w # w -> \ (warning) 00057 // x \ \ # \ -> x (warning) 00058 // y\ # y\ -> x 00059 // z z \#oops # z -> z; \#oops -> z 00060 // 00061 // The read-from-file function returns -1 if the file is not readable. 00062 // Otherwise both functions return the non-negative number of aliases 00063 // that where inconsistent with existing alias definitions. All such 00064 // errors are also reported explicitly to the specified output stream 00065 // (err). 00066 }; 00067 00068 #endif 00069
1.3.9.1