File: query_templates.C

package info (click to toggle)
mixviews 1.20-10.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,928 kB
  • ctags: 5,960
  • sloc: cpp: 32,879; ansic: 2,110; makefile: 445; sh: 17
file content (41 lines) | stat: -rw-r--r-- 983 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// query_templates.C

#ifndef QUERY_TEMPLATES_C
#define QUERY_TEMPLATES_C

#include "query_templates.h"
#include <String.h>

template <class Type>
Query<Type>::~Query() {
	delete setterGetter;
}

// convert whatever Type value is contained within into a char string
// the cast on this->tmpbuf allows writing into this const buffer, which is used
// for no other purpose than to store the string which is returned

template <class Type>
const char *
Query<Type>::get() const {
	return toString( ((Query<Type> *) this)->tmpbuf, setterGetter->get() );
}

// convert string to value of type Type, convert to double and confine it
// to the bounds Range, convert back to Type, and set the value

template <class Type>
boolean
Query<Type>::checkAndSet(const char* s) {
	Type t = Type(bounds.confine(double(fromString(s, (Type) 0))));
	return setterGetter->set(t);
}

template <class Type>
QueryItem::QueryType
Query<Type>::type() {
	return displayBounds ? RangedValue : Value;
}

#endif