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
163 const String& getKey()
const;
167 void setValue(
const String& value);
175 const String& getValue()
const;
183 Size countChildren()
const;
187 Size countDescendants()
const;
191 Size getSize()
const;
195 Size getDepth()
const;
217 bool mergeChildrenOf(
ResourceEntry& entry,
bool replace_value =
true);
225 bool removeKey(
const String& key_path);
258 bool hasChild(
const String& key)
const;
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];
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)
528 return stack_index_[--stack_size_];
532 ResourceEntry* bound_;
533 IteratorPosition position_;
535 Size stack_capacity_;
560 virtual void deleteEntryArray(
ResourceEntry** entry_array)
const;
568 bool findGreaterOrEqual_(
const String& key,
Index& found)
const;
574 Size number_children_;
635 virtual void clear();
646 bool open(
const String& name);
654 static void saveAs(
const Entry& entry,
const String& name);
658 void saveAs(
const String& name);
662 void save(
const Entry& entry);
675 Size getSize()
const;
683 const Entry& getRoot()
const;
691 const Entry* getEntry(
const String& key_path)
const;
707 bool removeKey(
const String& key_path);
725 bool hasKey(
const String& key_path)
const;
729 bool isEmpty()
const;
739 bool isValid()
const;
743 void dump(std::ostream& s = std::cout,
Size depth = 0)
const;
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>
817 #endif // BALL_FORMAT_RESOURCEFILE_H
ResourceEntry * IteratorPosition
const IteratorPosition & getPosition() const
IteratorTraits_(const ResourceEntry &entry)
ConstIterator end() const
std::istream & operator>>(std::istream &is, TRegularData1D< ValueType > &grid)
Input operator.
ResourceEntry & getData()
ConstIterator begin() const
Entry::ConstIterator ConstIterator
IteratorTraits_(const IteratorTraits_ &traits, bool=true)
ResourceEntry * getContainer()
virtual ~IteratorTraits_()
ForwardIterator< ResourceEntry, ResourceEntry, ResourceEntry *, IteratorTraits_ > Iterator
BALL_EXPORT bool operator!=(const String &s1, const String &s2)
#define BALL_CREATE_DEEP(name)
ConstIterator begin() const
const ResourceEntry & getData() const
const ResourceEntry * getContainer() const
BALL_EXPORT bool operator==(const String &s1, const String &s2)
ConstIterator end() const
IteratorPosition & getPosition()
ConstForwardIterator< ResourceEntry, ResourceEntry, ResourceEntry *, IteratorTraits_ > ConstIterator
static const Index INVALID_INDEX