15 #include "dcKeywordList.h"
16 #include "dcKeyword.h"
17 #include "hashGenerator.h"
37 _keywords(copy._keywords),
38 _keywords_by_name(copy._keywords_by_name),
50 _keywords = copy._keywords;
51 _keywords_by_name = copy._keywords_by_name;
62 nassertv(_keywords_by_name.size() == _keywords.size());
73 return (_keywords_by_name.find(name) != _keywords_by_name.end());
94 nassertr(_keywords_by_name.size() == _keywords.size(), 0);
95 return _keywords.size();
105 nassertr(n >= 0 && n < (
int)_keywords.size(), NULL);
118 KeywordsByName::const_iterator ni;
119 ni = _keywords_by_name.find(name);
120 if (ni != _keywords_by_name.end()) {
136 return _keywords_by_name == other._keywords_by_name;
158 bool inserted = _keywords_by_name.insert(KeywordsByName::value_type(keyword->
get_name(), keyword)).second;
160 _keywords.push_back(keyword);
175 _keywords_by_name.clear();
185 output_keywords(ostream &out)
const {
186 Keywords::const_iterator ki;
187 for (ki = _keywords.begin(); ki != _keywords.end(); ++ki) {
188 out <<
" " << (*ki)->get_name();
210 hashgen.
add_int(_keywords_by_name.size());
211 KeywordsByName::const_iterator ni;
212 for (ni = _keywords_by_name.begin(); ni != _keywords_by_name.end(); ++ni) {
213 (*ni).second->generate_hash(hashgen);
This represents a single keyword declaration in the dc file.
const DCKeyword * get_keyword(int n) const
Returns the nth keyword in the list.
This is a list of keywords (see DCKeyword) that may be set on a particular field. ...
int get_num_keywords() const
Returns the number of keywords in the list.
void add_int(int num)
Adds another integer to the hash so far.
bool compare_keywords(const DCKeywordList &other) const
Returns true if this list has the same keywords as the other list, false if some keywords differ...
This class generates an arbitrary hash number from a sequence of ints.
void copy_keywords(const DCKeywordList &other)
Replaces this keyword list with those from the other list.
bool add_keyword(const DCKeyword *keyword)
Adds the indicated keyword to the list.
int get_historical_flag() const
Returns the bitmask associated with this keyword, if any.
void generate_hash(HashGenerator &hashgen) const
Accumulates the properties of these keywords into the hash.
void clear_keywords()
Removes all keywords from the field.
const DCKeyword * get_keyword_by_name(const string &name) const
Returns the keyword in the list with the indicated name, or NULL if there is no keyword in the list w...
bool has_keyword(const string &name) const
Returns true if this list includes the indicated keyword, false otherwise.
const string & get_name() const
Returns the name of this keyword.