FreeCAD

Форк
0
/
fcoll.cpp 
89 строк · 2.7 Кб
1

2
#include "zipios-config.h"
3

4
#include <algorithm>
5
#include <string>
6
#include <vector>
7

8
#include "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 nullptr ;
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
*/
91

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.