Panda3D
Loading...
Searching...
No Matches
configDeclaration.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file configDeclaration.h
10 * @author drose
11 * @date 2004-10-15
12 */
13
14#ifndef CONFIGDECLARATION_H
15#define CONFIGDECLARATION_H
16
17#include "dtoolbase.h"
18#include "configFlags.h"
19#include "configPage.h"
20#include "vector_string.h"
21#include "numeric_types.h"
22#include "filename.h"
23
24#include <vector>
25
27
28/**
29 * A single declaration of a config variable, typically defined as one line in
30 * a .prc file, e.g. "show-frame-rate-meter 1". This is really just a
31 * pairing of a string name (actually, a ConfigVariableCore pointer) to a
32 * string value.
33 */
34class EXPCL_DTOOL_PRC ConfigDeclaration : public ConfigFlags {
35private:
37 const std::string &string_value, int decl_seq);
39
40public:
41 INLINE bool operator < (const ConfigDeclaration &other) const;
42
43PUBLISHED:
44 INLINE ConfigPage *get_page() const;
45 INLINE ConfigVariableCore *get_variable() const;
46 MAKE_PROPERTY(page, get_page);
47 MAKE_PROPERTY(variable, get_variable);
48
49 INLINE const std::string &get_string_value() const;
50 INLINE void set_string_value(const std::string &value);
51
52 INLINE size_t get_num_words() const;
53
54 INLINE bool has_string_word(size_t n) const;
55 INLINE bool has_bool_word(size_t n) const;
56 INLINE bool has_int_word(size_t n) const;
57 INLINE bool has_int64_word(size_t n) const;
58 INLINE bool has_double_word(size_t n) const;
59
60 INLINE std::string get_string_word(size_t n) const;
61 INLINE bool get_bool_word(size_t n) const;
62 INLINE int get_int_word(size_t n) const;
63 INLINE int64_t get_int64_word(size_t n) const;
64 INLINE double get_double_word(size_t n) const;
65
66 void set_string_word(size_t n, const std::string &value);
67 void set_bool_word(size_t n, bool value);
68 void set_int_word(size_t n, int value);
69 void set_int64_word(size_t n, int64_t value);
70 void set_double_word(size_t n, double value);
71
72 Filename get_filename_value() const;
73
74 INLINE int get_decl_seq() const;
75
76 void output(std::ostream &out) const;
77 void write(std::ostream &out) const;
78
79public:
80 static size_t extract_words(const std::string &str, vector_string &words);
81 static std::string downcase(const std::string &s);
82
83private:
84 void get_words();
85 void check_bool_word(size_t n);
86 void check_int_word(size_t n);
87 void check_int64_word(size_t n);
88 void check_double_word(size_t n);
89
90private:
91 ConfigPage *_page;
92 ConfigVariableCore *_variable;
93 std::string _string_value;
94 int _decl_seq;
95
96 enum WordFlags {
97 F_checked_bool = 0x0001,
98 F_valid_bool = 0x0002,
99 F_checked_int = 0x0004,
100 F_valid_int = 0x0008,
101 F_checked_double = 0x0010,
102 F_valid_double = 0x0020,
103 F_checked_int64 = 0x0040,
104 F_valid_int64 = 0x0080,
105 };
106
107 class Word {
108 public:
109 std::string _str;
110 bool _bool;
111 int _int;
112 int64_t _int_64;
113 double _double;
114 short _flags;
115 };
116
117 typedef std::vector<Word> Words;
118 Words _words;
119 bool _got_words;
120
121 friend class ConfigPage;
122};
123
124INLINE std::ostream &operator << (std::ostream &out, const ConfigDeclaration &decl);
125
126#include "configDeclaration.I"
127
128#endif
A single declaration of a config variable, typically defined as one line in a .prc file,...
This class is the base class of both ConfigVariable and ConfigVariableCore.
Definition configFlags.h:26
A page of ConfigDeclarations that may be loaded or unloaded.
Definition configPage.h:30
The internal definition of a ConfigVariable.
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int extract_words(const string &str, vector_string &words)
Divides the string into a number of words according to whitespace.
string downcase(const string &s)
Returns the input string with all uppercase letters converted to lowercase.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.