00001 /* -*-C-*- 00002 ******************************************************************************** 00003 * 00004 * File: choicearr.h (Formerly choicearr.h) 00005 * Description: 00006 * Author: Mark Seaman, SW Productivity 00007 * Created: Fri Oct 16 14:37:00 1987 00008 * Modified: Tue Mar 19 15:27:49 1991 (Mark Seaman) marks@hpgrlt 00009 * Language: C 00010 * Package: N/A 00011 * Status: Reusable Software Component 00012 * 00013 * (c) Copyright 1987, Hewlett-Packard Company. 00014 ** Licensed under the Apache License, Version 2.0 (the "License"); 00015 ** you may not use this file except in compliance with the License. 00016 ** You may obtain a copy of the License at 00017 ** http://www.apache.org/licenses/LICENSE-2.0 00018 ** Unless required by applicable law or agreed to in writing, software 00019 ** distributed under the License is distributed on an "AS IS" BASIS, 00020 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00021 ** See the License for the specific language governing permissions and 00022 ** limitations under the License. 00023 * 00024 ******************************************************************************** 00025 */ 00026 00027 #ifndef CHOICEARR_H 00028 #define CHOICEARR_H 00029 00030 /* 00031 ---------------------------------------------------------------------- 00032 I n c l u d e s 00033 ---------------------------------------------------------------------- 00034 */ 00035 00036 #include "tessarray.h" 00037 #include "choices.h" 00038 00039 /* 00040 ---------------------------------------------------------------------- 00041 T y p e s 00042 ---------------------------------------------------------------------- 00043 */ 00044 00045 typedef ARRAY CHOICES_LIST; 00046 00047 #define CHOICES_PER_LIST 40 00048 00049 /* 00050 ---------------------------------------------------------------------- 00051 M a c r o s 00052 ---------------------------------------------------------------------- 00053 */ 00054 00055 /********************************************************************** 00056 * free_choice_list 00057 * 00058 * Free a list of choices. Free the array structure but not each of the 00059 * sublists of choices. 00060 **********************************************************************/ 00061 00062 #define free_choice_list(choice_list) \ 00063 array_free (choice_list) 00064 00065 /********************************************************************** 00066 * for_each_choice 00067 * 00068 * Iterate through each of the possible choices. 00069 **********************************************************************/ 00070 00071 #define for_each_choice(array,index) \ 00072 array_loop (array, index) 00073 00074 /********************************************************************** 00075 * free_all_choices 00076 * 00077 * Free an array of choices (deep free). 00078 **********************************************************************/ 00079 00080 #define free_all_choices(choices,index) \ 00081 for_each_choice (choices, index) { \ 00082 free_choices ((CHOICES) array_value (choices, index)); \ 00083 } \ 00084 array_free (choices) \ 00085 00086 00087 /********************************************************************** 00088 * new_choice_list 00089 * 00090 * Return a new array structure that is a list of choices. Each set of 00091 * choices will be of type CHOICES. 00092 **********************************************************************/ 00093 00094 #define new_choice_list() \ 00095 array_new (CHOICES_PER_LIST) 00096 #endif