STRING_VARIABLE::STRING_VARIABLE ( //constructor const char *v, //the variable const char *vname, //of variable const char *comment //info on variable ): value(v) { // list iterator STRING_VARIABLE_C_IT it = &head; name = vname; // strings must be static info = comment; it.add_before_stay_put(this); // add it to stack }
// constructor STRING_VARIABLE::~STRING_VARIABLE( ) { // list iterator STRING_VARIABLE_C_IT it = &head; for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) if (it.data() == this) it.extract(); }
void STRING_VARIABLE::print(FILE *fp) { STRING_VARIABLE_C_IT it = &head; // list iterator STRING_VARIABLE *elt; // current element // Comments aren't allowed with string variables, so the # character can // be part of a string. if (fp == stdout) { tprintf("#Variables of type STRING_VARIABLE:\n"); for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) { elt = it.data(); tprintf("%s %s\n", elt->name, elt->value.string()); } } else { fprintf(fp, "#Variables of type STRING_VARIABLE:\n"); for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) { elt = it.data(); fprintf(fp, "%s %s\n", elt->name, elt->value.string()); } } }
void STRING_VARIABLE::print(FILE *fp // file to print on ) { // list iterator STRING_VARIABLE_C_IT it = &head; STRING_VARIABLE *elt; // current element if (fp == stdout) { printf("#Variables of type STRING_VARIABLE:\n"); for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) { elt = it.data(); printf("%s #%s %s\n", elt->name, elt->value.string(), elt->info); } } else { fprintf(fp, "#Variables of type STRING_VARIABLE:\n"); for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) { elt = it.data(); fprintf(fp, "%s #%s %s\n", elt->name, elt->value.string(), elt->info); } } }