5#ifndef BALL_FORMAT_RESOURCEFILE_H
6#define BALL_FORMAT_RESOURCEFILE_H
12#ifndef BALL_CONCEPT_FORWARDITERATOR_H
16#ifndef BALL_CONCEPT_VISITOR_H
20#ifndef BALL_CONCEPT_AUTODELETABLE_H
24#ifndef BALL_CONCEPT_PROCESSOR_H
28#ifndef BALL_SYSTEM_FILE_H
262 bool isEmpty() const;
295 bool isValid() const;
298 void dump(
std::ostream& s =
std::cout,
Size depth = 0) const;
330 stack_index_(new
Index[1]),
339 stack_index_(new
Index[1]),
346 : bound_(traits.bound_),
347 position_(traits.position_),
348 stack_index_(new
Index[traits.stack_capacity_]),
349 stack_capacity_(traits.stack_capacity_),
350 stack_size_(traits.stack_size_)
352 for (
Index index = 0; index < (
Index)stack_capacity_; ++index)
353 stack_index_[index] = traits.stack_index_[index];
358 delete[] stack_index_;
363 bound_ = traits.bound_;
364 position_ = traits.position_;
365 delete[] stack_index_;
366 stack_index_ =
new Index[traits.stack_capacity_];
367 stack_capacity_ = traits.stack_capacity_;
368 stack_size_ = traits.stack_size_;
370 for (
Index index = 0; index < (
Index)stack_capacity_; ++index)
372 stack_index_[index] = traits.stack_index_[index];
390 return (bound_ == 0);
405 return (position_ == traits.position_);
410 return (position_ != traits.position_);
415 return (bound_ != 0 && position_ != 0
417 && stack_size_ <= stack_capacity_
418 && stack_capacity_ > 0);
436 return (position_ == bound_);
446 return (position_ == 0);
461 if (position_->number_children_ > 0)
463 position_ = position_->child_[0];
469 Index next_child = INVALID_Index;
474 if (next_child == INVALID_Index)
481 position_ = position_->parent_;
484 }
while(++next_child >= (
Index)position_->number_children_);
487 position_ = position_->child_[next_child];
499 void push(
Index next_child)
501 if (stack_size_ >= stack_capacity_)
503 Index *new_stack_index =
new Index[stack_capacity_ << 1];
505 for (
Index index = 0; index < (
Index)stack_capacity_; ++index)
507 new_stack_index[index] = stack_index_[index];
510 delete[] stack_index_;
511 stack_index_ = new_stack_index;
512 stack_capacity_ <<= 1;
515 stack_index_[stack_size_] = next_child;
522 if (stack_size_ == 0)
524 return INVALID_Index;
528 return stack_index_[--stack_size_];
532 ResourceEntry* bound_;
533 IteratorPosition position_;
535 Size stack_capacity_;
568 bool findGreaterOrEqual_(
const String& key,
Index& found)
const;
574 Size number_children_;
743 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
753 friend std::istream& operator >> (std::istream& s,
ResourceFile& resource_file);
777 return Iterator::begin(root_);
782 return Iterator::end(root_);
790 return ConstIterator::begin(root_);
795 return ConstIterator::end(root_);
803 static void save_(
File& file,
const Entry* entry,
Size& depth);
805 bool validateSyntax_();
807 void skipWhitespaces_();
812# ifndef BALL_NO_INLINE_FUNCTIONS
813# include <BALL/FORMAT/resourceFile.iC>
#define BALL_CREATE_DEEP(name)
virtual ResourceEntry * newEntry(const String &key, const String &value, ResourceEntry *parent=0) const
ForwardIterator< ResourceEntry, ResourceEntry, ResourceEntry *, IteratorTraits_ > Iterator
virtual void deleteEntry(ResourceEntry *entry) const
bool applyNostart_(UnaryProcessor< ResourceEntry > &processor)
ConstForwardIterator< ResourceEntry, ResourceEntry, ResourceEntry *, IteratorTraits_ > ConstIterator
virtual void deleteEntryArray(ResourceEntry **entry_array) const
ConstIterator begin() const
ConstIterator end() const
virtual ResourceEntry ** newEntryArray(Size size) const
IteratorTraits_(const ResourceEntry &entry)
const ResourceEntry * getContainer() const
IteratorTraits_(const IteratorTraits_ &traits, bool=true)
const IteratorPosition & getPosition() const
ResourceEntry & getData()
ResourceEntry * getContainer()
IteratorPosition & getPosition()
const ResourceEntry & getData() const
virtual ~IteratorTraits_()
void dump(std::ostream &s=std::cout, Size depth=0) const
bool hasKey(const String &key_path) const
void save(const Entry &entry)
const Entry & getRoot() const
static void saveAs(const Entry &entry, const String &name)
ConstIterator begin() const
bool apply(UnaryProcessor< Entry > &processor)
const String * getValue(const String &key_path) const
void saveAs(const String &name)
bool open(const String &name)
String * getValue(const String &key_path)
void host(Visitor< ResourceFile > &visitor)
static bool applyChildren(Entry &entry, UnaryProcessor< Entry > &processor)
Entry::ConstIterator ConstIterator
ConstIterator end() const
Entry * getEntry(const String &key_path)
bool removeKey(const String &key_path)
const Entry * getEntry(const String &key_path) const
ResourceFile(const String &name)
Entry * insert(const String &key_path, const String &name)