~ubuntu-branches/ubuntu/intrepid/enigma/intrepid

« back to all changes in this revision

Viewing changes to lib-src/zipios++/src/fcoll.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Erich Schubert
  • Date: 2005-08-28 15:30:09 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050828153009-sky64kb6tcq37xt5
Tags: 0.92.1-1
* New upstream subversion checkout
* Remove menu.s3m, which we are allowed to distributed but not to modify
  also copyright notice is confusing... (Closes: #321669)
* Rebuild with new libzipios (Closes: #325405)
  I hope this works without a versioned build-dependency
* Added "enigma replaces enigma-data" for upgrades (Closes: #308558)
* Added notes about the fonts copyright.
* updated to policy 3.6.2.1 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include "zipios++/zipios-config.h"
3
 
 
4
 
#include <algorithm>
5
 
#include <string>
6
 
#include <vector>
7
 
 
8
 
#include "zipios++/fcoll.h"
9
 
 
10
 
namespace zipios {
11
 
 
12
 
using std::find_if ;
13
 
 
14
 
// FIXME: make InvalidStateException message customized for
15
 
// subclasses. maybe make an InvalidStateException factory ;-)
16
 
 
17
 
ConstEntries FileCollection::entries() const {
18
 
  if ( ! _valid )
19
 
    throw InvalidStateException( "Attempt to get entries from an invalid FileCollection" ) ;
20
 
 
21
 
  // The constructor below is not in all vector impl. (not those
22
 
  // without member templates)
23
 
  // ConstEntries ( _entries.begin(), _entries.end() ) ;
24
 
  // Instead of using that we copy the vector manually
25
 
  ConstEntries cep_vec ;
26
 
  cep_vec.reserve( _entries.size() ) ;
27
 
  Entries::const_iterator cit ;
28
 
  for ( cit = _entries.begin() ; cit != _entries.end() ; ++cit )
29
 
    cep_vec.push_back( *cit ) ;
30
 
 
31
 
  return cep_vec ;
32
 
}
33
 
 
34
 
ConstEntryPointer FileCollection::getEntry( const string &name, 
35
 
                                           MatchPath matchpath ) const {
36
 
  if ( ! _valid )
37
 
    throw InvalidStateException( "Attempt to get an entry from an invalid FileCollection" ) ;
38
 
 
39
 
  Entries::const_iterator iter ;
40
 
  if ( matchpath == MATCH )
41
 
    iter = find_if( _entries.begin(), _entries.end(), FileEntry::MatchName( name ) ) ;
42
 
  else
43
 
    iter = find_if( _entries.begin(), _entries.end(), FileEntry::MatchFileName( name ) ) ;
44
 
  if ( iter == _entries.end() )
45
 
    return 0 ;
46
 
  else
47
 
    return *iter ; 
48
 
}
49
 
 
50
 
string FileCollection::getName() const {
51
 
  if ( ! _valid )
52
 
    throw InvalidStateException( "Attempt to get the name of an invalid FileCollection" ) ;
53
 
  return _filename ;
54
 
}
55
 
 
56
 
 
57
 
int FileCollection::size() const {
58
 
  if ( ! _valid )
59
 
    throw InvalidStateException( "Attempt to get size of an invalid FileCollection" ) ;
60
 
  return _entries.size() ;
61
 
}
62
 
 
63
 
FileCollection::~FileCollection() {
64
 
}
65
 
 
66
 
 
67
 
} // namespace
68
 
 
69
 
/** \file
70
 
    Implementation of FileCollection.
71
 
*/
72
 
 
73
 
/*
74
 
  Zipios++ - a small C++ library that provides easy access to .zip files.
75
 
  Copyright (C) 2000  Thomas S�ndergaard
76
 
  
77
 
  This library is free software; you can redistribute it and/or
78
 
  modify it under the terms of the GNU Lesser General Public
79
 
  License as published by the Free Software Foundation; either
80
 
  version 2 of the License, or (at your option) any later version.
81
 
  
82
 
  This library is distributed in the hope that it will be useful,
83
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
84
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
85
 
  Lesser General Public License for more details.
86
 
  
87
 
  You should have received a copy of the GNU Lesser General Public
88
 
  License along with this library; if not, write to the Free Software
89
 
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
90
 
*/