as_prop_flags.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 
00018 #ifndef GNASH_AS_PROP_FLAGS_H
00019 #define GNASH_AS_PROP_FLAGS_H
00020 
00021 #ifdef HAVE_CONFIG_H
00022 #include "gnashconfig.h"
00023 #endif
00024 
00025 namespace gnash {
00026 
00028 class as_prop_flags
00029 {
00030 
00032         int _flags;
00033 
00035         bool _protected;
00036 
00037 public:
00038 
00040         enum Flags {
00041 
00043                 dontEnum        = 1 << 0,
00044 
00046                 dontDelete      = 1 << 1,
00047 
00049                 readOnly        = 1 << 2,
00050 
00052                 staticProp      = 1 << 3,
00053 
00055                 isProtected     = 1 << 4,
00056 
00058                 onlySWF6Up      = 1 << 7, // 128
00059 
00061                 ignoreSWF6      = 1 << 8, // 256
00062 
00064                 onlySWF7Up      = 1 << 10, // 1024
00065 
00067                 onlySWF8Up      = 1 << 12 // 4096
00068 
00069         };
00070 
00072         //
00076         static const int as_prop_flags_mask = dontEnum|dontDelete|readOnly|onlySWF6Up|ignoreSWF6|onlySWF7Up|onlySWF8Up;
00077 
00078 
00080         as_prop_flags() : _flags(0)
00081         {
00082         }
00083 
00085         as_prop_flags(const bool read_only, const bool dont_delete, const bool dont_enum)
00086                 :
00087                 _flags(((read_only) ? readOnly : 0) |
00088                                 ((dont_delete) ? dontDelete : 0) |
00089                                 ((dont_enum) ? dontEnum : 0))
00090         {
00091         }
00092 
00094         as_prop_flags(const int flags)
00095                 : _flags(flags)
00096         {
00097         }
00098 
00099         bool operator== (const as_prop_flags& o) const
00100         {
00101                 return ( _flags == o._flags );
00102         }
00103 
00104         bool operator!= (const as_prop_flags& o) const
00105         {
00106                 return ( _flags != o._flags );
00107         }
00108 
00110         bool get_static() const { return (_flags & staticProp) ? true : false; }
00111 
00113         void set_static() { _flags |= staticProp; }
00114 
00116         void clear_static() { _flags &= ~staticProp; }
00117 
00119         bool get_read_only() const { return (((_flags & readOnly)!=0)?true:false); }
00120 
00122         void set_read_only() { _flags |= readOnly; }
00123 
00125         void clear_read_only() { _flags &= ~readOnly; }
00126 
00128         bool get_dont_delete() const { return (((_flags & dontDelete)!=0)?true:false); }
00129 
00131         void set_dont_delete() { _flags |= dontDelete; }
00132 
00134         void clear_dont_delete() { _flags &= ~dontDelete; }
00135 
00137         bool get_dont_enum() const { return (((_flags & dontEnum)!=0)?true:false);      }
00138 
00140         void set_dont_enum() { _flags |= dontEnum; }
00141 
00143         void clear_dont_enum() { _flags &= ~dontEnum; }
00144 
00146         bool get_visible(int swfVersion) const
00147         {
00148                 if ( _flags & onlySWF6Up && swfVersion  < 6 ) return false;
00149                 if ( _flags & ignoreSWF6 && swfVersion == 6 ) return false;
00150                 if ( _flags & onlySWF7Up && swfVersion  < 7 ) return false;
00151                 if ( _flags & onlySWF8Up && swfVersion < 8 ) return false;
00152                 return true;
00153         }
00154 
00155         void clear_visible(int swfVersion) 
00156         {
00157                 if ( swfVersion == 6)
00158                 {
00159                         // version 6, so let's forget SWFDEC_AS_VARIABLE_VERSION_7_UP flag, oops!
00160                         // we will still set the value though, even if that flag is set
00161                         _flags &= ~(onlySWF6Up|ignoreSWF6|onlySWF8Up);
00162                 }
00163                 else
00164                 {
00165                         _flags &= ~(onlySWF6Up|ignoreSWF6|onlySWF7Up|onlySWF8Up);
00166                 }
00167         }
00168 
00170         int get_flags() const { return _flags; }
00171 
00173         bool get_is_protected() const { return (_flags & isProtected) ? true : false; }
00174 
00176         //
00177         void set_is_protected(const bool is_protected)
00178         {
00179                 if (is_protected)
00180                         _flags |= isProtected;
00181                 else
00182                         _flags &= ~isProtected;
00183         }
00184 
00198         bool set_flags(const int setTrue, const int setFalse = 0)
00199         {
00200                 if (get_is_protected()) return false;
00201 
00202                 _flags &= ~setFalse;
00203                 _flags |= setTrue;
00204 
00205                 return true;
00206         }
00207 };
00208 
00209 
00210 
00211 } // namespace gnash
00212 
00213 #endif // GNASH_AS_PROP_FLAGS_H

Generated on Thu Mar 6 18:25:06 2008 for Gnash by  doxygen 1.5.4