COVISE Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
ChoiceList.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef __CHOICE_LIST_H_
9 #define __CHOICE_LIST_H_
10 
11 #include "coExport.h"
12 #include <iostream>
13 #include <cstring>
14 
15 namespace covise
16 {
17 
19 {
20 
21 private:
22  ChoiceList(const ChoiceList &);
23  ChoiceList &operator=(const ChoiceList &);
24  ChoiceList();
25 
26  char *choiceString[64];
27  int choiceNo[64];
29 
30 public:
31  ChoiceList(const char *choice0, int choiceNo0)
32  {
33  choiceString[0] = new char[strlen(choice0) + 1];
34  strcpy(choiceString[0], choice0);
35  choiceNo[0] = choiceNo0;
36  numChoices = 1;
37  }
38 
39  int add(const char *choice, int number)
40  {
41  int retval;
42  if (numChoices == 64)
43  retval = 1;
44  else
45  {
46  choiceString[numChoices] = new char[strlen(choice) + 1];
47  strcpy(choiceString[numChoices], choice);
48  choiceNo[numChoices] = number;
49  numChoices++;
50  retval = 0;
51  }
52  return retval;
53  }
54 
55  int change(const char *newchoice, int number)
56  {
57  delete[] choiceString[number];
58  choiceString[number] = new char[strlen(newchoice) + 1];
59  strcpy(choiceString[number], newchoice);
60  return 0;
61  }
62  int get_orig_num(int choice) const
63  {
64  return choiceNo[choice];
65  }
66 
67  const char *getString(int choice)
68  {
69  return choiceString[choice];
70  }
71 
72  const char *const *get_strings() const
73  {
74  return choiceString;
75  }
76 
77  int get_num() const
78  {
79  return numChoices;
80  }
81 
82  friend std::ostream &operator<<(std::ostream &, const ChoiceList &);
83 };
84 
85 std::ostream &operator<<(std::ostream &, const ChoiceList &);
86 }
87 #endif
const char * getString(int choice)
Definition: ChoiceList.h:67
ChoiceList(const char *choice0, int choiceNo0)
Definition: ChoiceList.h:31
int numChoices
Definition: ChoiceList.h:28
int get_orig_num(int choice) const
Definition: ChoiceList.h:62
int add(const char *choice, int number)
Definition: ChoiceList.h:39
int get_num() const
Definition: ChoiceList.h:77
#define UTILEXPORT
Definition: coExport.h:182
const char *const * get_strings() const
Definition: ChoiceList.h:72
Definition: ChoiceList.h:18
QTextStream & operator<<(QTextStream &out, const coConfigEntryStringList list)
Definition: coConfigEntryString.cpp:166
int change(const char *newchoice, int number)
Definition: ChoiceList.h:55