00001 // -*- C++ -*- 00002 // $Id: flags.h,v 1.1 2000/10/24 16:22:47 eldamitri Exp $ 00003 00004 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags 00005 // Copyright 1999, 2000 Scott Thomas Haug 00006 00007 // This library is free software; you can redistribute it and/or modify it 00008 // under the terms of the GNU Library General Public License as published by 00009 // the Free Software Foundation; either version 2 of the License, or (at your 00010 // option) any later version. 00011 // 00012 // This library is distributed in the hope that it will be useful, but WITHOUT 00013 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00015 // License for more details. 00016 // 00017 // You should have received a copy of the GNU Library General Public License 00018 // along with this library; if not, write to the Free Software Foundation, 00019 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 00021 // The id3lib authors encourage improvements and optimisations to be sent to 00022 // the id3lib coordinator. Please see the README file for details on where to 00023 // send such submissions. See the AUTHORS file for a list of people who have 00024 // contributed to id3lib. See the ChangeLog file for a list of changes to 00025 // id3lib. These files are distributed with id3lib at 00026 // http://download.sourceforge.net/id3lib/ 00027 00028 #ifndef _ID3LIB_FLAGS_H_ 00029 #define _ID3LIB_FLAGS_H_ 00030 00031 #include "flags.h" 00032 00033 class ID3_Flags 00034 { 00035 public: 00036 typedef flags_t TYPE; 00037 00038 ID3_Flags() : _f(0) { ; } 00039 virtual ~ID3_Flags() { ; } 00040 00041 TYPE get() const { return _f; } 00042 bool test(TYPE f) const { return (this->get() & f) == f; } 00043 bool set(TYPE f) { bool r = (_f != f); _f = f; return r; } 00044 bool add(TYPE f) { return this->set(this->get() | f); } 00045 bool remove(TYPE f) { return this->set(this->get() & ~f); } 00046 bool clear() { return this->set(0); } 00047 bool set(TYPE f, bool b){ if (b) return this->add(f); return this->remove(f); } 00048 00049 ID3_Flags& operator=(const ID3_Flags& f) 00050 { if (this != &f) { this->set(f.get()); } return *this; } 00051 00052 private: 00053 TYPE _f; 00054 }; 00055 00056 #endif /* _ID3LIB_FLAGS_H_ */