/usr/include/root/Reflex/internal/PropertyListImpl.h is in libroot-core-dev 5.34.30-0ubuntu8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | // @(#)root/reflex:$Id$
// Author: Stefan Roiser 2004
// Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.
#ifndef Reflex_PropertyListImpl
#define Reflex_PropertyListImpl
// Include files
#include "Reflex/Kernel.h"
#include "Reflex/Any.h"
#include <map>
#include <iostream>
#ifdef _WIN32
# pragma warning( push )
# pragma warning( disable : 4251 )
#endif
namespace Reflex {
/**
* @class PropertyList PropertyList.h Reflex/PropertyList.h
* @author Stefan Roiser
* @date 24/11/2003
* @ingroup Ref
*/
class RFLX_API PropertyListImpl {
friend RFLX_API std::ostream& operator <<(std::ostream& s,
const PropertyListImpl& p);
public:
/** default constructor */
PropertyListImpl();
/** copy constructor */
PropertyListImpl(const PropertyListImpl &pl);
/** destructor */
virtual ~PropertyListImpl();
/** assignment op */
PropertyListImpl& operator=(const PropertyListImpl &pl);
/**
* AddProperty will add a key value pair to the PropertyNth lsit
* @param key the key of the PropertyNth
* @param value the value of the PropertyNth (as any object)
* @return the property key of this property
*/
size_t AddProperty(const std::string& key,
const Any& value);
/**
* AddProperty will add a property value pair to the property list
* @param key the key of the property
* @param value the value of the property (as any object)
*/
void AddProperty(size_t key,
const Any& value);
/**
* AddProperty will add a key value pair to the PropertyNth lsit
* @param key the key of the PropertyNth
* @param value the value of the PropertyNth (as any object)
* @return the property key of this property
*/
size_t AddProperty(const std::string& key,
const char* value);
/**
* AddProperty will add a key value pair to the property list
* @param key the key of the property
* @param value the value of the property (as any object)
*/
void AddProperty(size_t key,
const char* value);
/**
* ClearProperties will remove all properties from the list
*/
void ClearProperties();
/**
* HasProperty will return true if the property list contains a key "key" and
* the property for this key is valid
* @param key to look for
* @return true if a valid property for key exists
*/
bool HasProperty(const std::string& key) const;
/**
* HasProperty will return true if the property list contains a key "key" and
* the property for this key is valid
* @param key to look for
* @return true if a valid property for key exists
*/
bool HasProperty(size_t key) const;
/**
* Key_Begin will return the begin iterator of the key container
* @return begin iterator of key container
*/
static StdString_Iterator Key_Begin();
/**
* Key_End will return the end iterator of the key container
* @return end iterator of key container
*/
static StdString_Iterator Key_End();
/**
* Key_RBegin will return the rbegin iterator of the key container
* @return rbegin iterator of key container
*/
static Reverse_StdString_Iterator Key_RBegin();
/**
* Key_REnd will return the rend iterator of the key container
* @return rend iterator of key container
*/
static Reverse_StdString_Iterator Key_REnd();
/**
* KeysAsString will return a space separated list of all keys
* @return a list of all currently allocated keys
*/
static std::string KeysAsString();
/**
* KeyAt will return the nth key allocated
* @param nth key currently allocated
* @return key as a string
*/
static const std::string& KeyAt(size_t nth);
/**
* Key is the static getter function to return the index of a key. If allocateNew is
* set to true a new key will be allocated if it doesn't exist and it's index returned.
* Otherwise if the key exists the function returns it's index or 0 if no key exists.
* @param key the key to look for
* @param allocateNew allocate a new key if the key doesn't exist
* @return key index or 0 if no key exists and allocateNew is set to false
*/
static size_t KeyByName(const std::string& key,
bool allocateNew = false);
/**
* KeySize will return the number of currently allocated keys
* @return number of allocated keys
*/
static size_t KeySize();
/**
* propertyNumString will return the nth PropertyNth as a string if printable
* @param key the PropertyNth key
* @return nth PropertyNth value as string
*/
std::string PropertyAsString(const std::string& key) const;
/**
* PropertyAsString will return the property value as a string if it exists
* The parameter is a property key which can be aquired with the PropertyKey method.
* @param key property key to look for
* @return string representation of the property
*/
std::string PropertyAsString(size_t key) const;
/**
* PropertyKey will return the the key value corresponding to the parameter given
* @param key the string denoting the key value to lookup
* @param allocateNew if set to true a new key will be allocated if it doesn't exist
if set to false and the key doesn't exist the function returns 0
* @return the key value corresponding to the key param
*/
size_t PropertyKey(const std::string& key,
bool allocateNew = false) const;
/**
* PropertyKeys will return all keys of this PropertyNth list
* @return all PropertyNth keys
*/
std::string PropertyKeys() const;
/**
* PropertyCount will return the number of properties attached
* to this item
* @return number of properties
*/
size_t PropertyCount() const;
/**
* propertyNumValue will return the nth PropertyNth value
* @param key the PropertyNth key
* @return nth PropertyNth value
*/
Any& PropertyValue(const std::string& key) const;
/**
* PropertyAsString will return the property value as an Any object if it exists
* The parameter is a property key which can be aquired with the PropertyKey method.
* @param key property key to look for
* @return Any representation of the property
*/
Any& PropertyValue(size_t key) const;
/**
* RemoveProperty will remove a key value pair to the PropertyNth lsit
* @param key the key of the PropertyNth
*/
void RemoveProperty(const std::string& key);
/**
* RemoveProperty will remove a property value from the property list
* @param key of the property identified by the property key number
*/
void RemoveProperty(size_t key);
private:
/**
* the Property container
*/
typedef std::vector<Any> Properties;
/** the properties of the item
* @label properties
* @link aggregationByValue
* @clientCardinality 1
* @supplierCardinality 0..1
*/
std::vector<Any>* fProperties;
}; // class PropertyListImpl
/**
* will put the PropertyNth (key and value) on the ostream if printable
* @param s the reference to the stream
* @return the stream
*/
RFLX_API std::ostream& operator <<(std::ostream& s,
const PropertyListImpl& p);
} //namespace Reflex
//-------------------------------------------------------------------------------
inline Reflex::PropertyListImpl::PropertyListImpl()
//-------------------------------------------------------------------------------
: fProperties(0) {
}
//-------------------------------------------------------------------------------
inline Reflex::PropertyListImpl::PropertyListImpl(const PropertyListImpl& pl)
//-------------------------------------------------------------------------------
: fProperties(pl.fProperties) {
}
//-------------------------------------------------------------------------------
inline
Reflex::PropertyListImpl&
Reflex::PropertyListImpl::operator=(const PropertyListImpl& pl) {
//-------------------------------------------------------------------------------
if (&pl != this) {
fProperties = pl.fProperties;
}
return *this;
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::PropertyListImpl::AddProperty(const std::string& key,
const Any& value) {
//-------------------------------------------------------------------------------
size_t k = PropertyKey(key, true);
AddProperty(k, value);
return k;
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyListImpl::AddProperty(size_t key,
const Any& value) {
//-------------------------------------------------------------------------------
if (!fProperties) {
fProperties = new Properties();
}
if (key >= fProperties->size()) {
fProperties->resize(key + 1, Dummy::Any());
}
(*fProperties)[key] = value;
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::PropertyListImpl::AddProperty(const std::string& key,
const char* value) {
//-------------------------------------------------------------------------------
return AddProperty(key, Any(value));
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyListImpl::AddProperty(size_t key,
const char* value) {
//-------------------------------------------------------------------------------
AddProperty(key, Any(value));
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyListImpl::RemoveProperty(const std::string& key) {
//-------------------------------------------------------------------------------
RemoveProperty(PropertyKey(key));
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyListImpl::RemoveProperty(size_t key) {
//-------------------------------------------------------------------------------
if (fProperties) {
fProperties->at(key).Swap(Dummy::Any());
}
}
#ifdef _WIN32
# pragma warning( pop )
#endif
#endif // Reflex_PropertyListImpl
|