feisty meow concerns codebase 2.140
filename_tree.cpp
Go to the documentation of this file.
1/*****************************************************************************\
2* *
3* Name : filename_tree *
4* Author : Chris Koeritz *
5* *
6*******************************************************************************
7* Copyright (c) 2004-$now By Author. This program is free software; you can *
8* redistribute it and/or modify it under the terms of the GNU General Public *
9* License as published by the Free Software Foundation; either version 2 of *
10* the License or (at your option) any later version. This is online at: *
11* http://www.fsf.org/copyleft/gpl.html *
12* Please send any updates to: fred@gruntose.com *
13\*****************************************************************************/
14
15#include "filename_tree.h"
16
18
19using namespace basis;
20using namespace nodes;
21using namespace structures;
22
23namespace filesystem {
24
26
28
30
32
36
37void filename_tree::pack(byte_array &packed_form) const {
38 structures::attach(packed_form, _depth);
39 _dirname.pack(packed_form);
40 _files.pack(packed_form);
41}
42
44 if (!structures::detach(packed_form, _depth)) return false;
45 if (!_dirname.unpack(packed_form)) return false;
46 if (!_files.unpack(packed_form)) return false;
47 return true;
48}
49
50} //namespace.
51
52
A very common template for a dynamic array of bytes.
Definition byte_array.h:36
virtual void pack(basis::byte_array &packed_form) const
Creates a packed form of the packable object in "packed_form".
virtual bool unpack(basis::byte_array &packed_form)
Restores the packable from the "packed_form".
virtual int packed_size() const
Estimates the space needed for the packed structure.
int _depth
how far below root node are we.
filename_list _files
the filenames that are at this node in the tree.
filename _dirname
the full directory name at this position.
virtual int packed_size() const
Estimates the space needed for the packed structure.
virtual void pack(basis::byte_array &packed_form) const
Creates a packed form of the packable object in "packed_form".
virtual bool unpack(basis::byte_array &packed_form)
Restores the packable from the "packed_form".
virtual bool unpack(basis::byte_array &packed_form)
Restores the packable from the "packed_form".
Definition filename.cpp:471
virtual void pack(basis::byte_array &packed_form) const
Creates a packed form of the packable object in "packed_form".
Definition filename.cpp:465
virtual int packed_size() const
Estimates the space needed for the packed structure.
Definition filename.cpp:460
virtual nodes::packable_tree * create()
implements the create() method for filename_trees to support packing.
A tree object that can be packed into an array of bytes and unpacked again.
void reset()
cleans out all of the contents.
Definition amorph.h:81
The guards collection helps in testing preconditions and reporting errors.
Definition array.h:30
A platform independent way to obtain the timestamp of a file.
A dynamic container class that holds any kind of object via pointers.
Definition amorph.h:55
void attach(byte_array &packed_form, const byte_array &to_attach)
Packs a byte_array "to_attach" into "packed_form".
const int PACKED_SIZE_INT32
bool detach(byte_array &packed_form, byte_array &to_detach)
Unpacks a byte_array "to_detach" from "packed_form".