2 * Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #include <ZLOptions.h>
21 #include <ZLStringUtil.h>
25 static std::string GROUP
= "BookList";
26 static std::string BOOK
= "Book";
27 static std::string SIZE
= "Size";
29 BookList::BookList() {
30 int size
= ZLIntegerOption(ZLCategoryKey::STATE
, GROUP
, SIZE
, 0).value();
31 for (int i
= 0; i
< size
; ++i
) {
32 std::string optionName
= BOOK
;
33 ZLStringUtil::appendNumber(optionName
, i
);
34 ZLStringOption
bookOption(ZLCategoryKey::STATE
, GROUP
, optionName
, "");
35 const std::string
&fileName
= bookOption
.value();
36 if (!fileName
.empty()) {
37 addFileName(fileName
);
42 BookList::~BookList() {
43 ZLIntegerOption(ZLCategoryKey::STATE
, GROUP
, SIZE
, 0).setValue(myFileNames
.size());
45 for (std::set
<std::string
>::const_iterator it
= myFileNames
.begin(); it
!= myFileNames
.end(); ++i
, ++it
) {
46 std::string optionName
= BOOK
;
47 ZLStringUtil::appendNumber(optionName
, i
);
48 ZLStringOption(ZLCategoryKey::STATE
, GROUP
, optionName
, "").setValue(*it
);
52 void BookList::addFileName(const std::string
&fileName
) {
53 myFileNames
.insert(fileName
);
56 void BookList::removeFileName(const std::string
&fileName
) {
57 myFileNames
.erase(fileName
);