/usr/include/root/Reflex/PropertyList.h is in libroot-core-dev 5.34.00-2.
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 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | // @(#)root/reflex:$Id: PropertyList.h 44094 2012-05-03 14:50:12Z axel $
// 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_PropertyList
#define Reflex_PropertyList
// Include files
#include "Reflex/Kernel.h"
#include <iostream>
namespace Reflex {
// forward declarations
class PropertyListImpl;
class Any;
/**
* @class PropertyList PropertyList.h Reflex/PropertyList.h
* @author Stefan Roiser
* @date 24/11/2003
* @ingroup Ref
*/
class RFLX_API PropertyList {
friend class OwnedPropertyList;
friend RFLX_API std::ostream& operator <<(std::ostream& s,
const PropertyList& p);
public:
/** default constructor */
PropertyList(PropertyListImpl * propertyListImpl = 0);
/** copy constructor */
PropertyList(const PropertyList &pl);
/** destructor */
~PropertyList();
/** assignment op */
PropertyList& operator=(const PropertyList &pl);
/**
* operator bool will return true if the property list is implemented
* @return true if property list is not a fake one
*/
operator bool() const;
/**
* 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)
* @return the property key of this property
*/
size_t AddProperty(const std::string& key,
const Any& value) const;
/**
* 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) const;
/**
* AddProperty will add a key value pair to the property lsit
* @param key the key of the property
* @param value the value of the property (as any object)
* @return the property key of this property
*/
size_t AddProperty(const std::string& key,
const char* value) const;
/**
* 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) const;
/**
* ClearProperties will remove all properties from the list
*/
void ClearProperties() const;
/**
* HasKey is deprecated. Use HasProperty instead with exactly the same functionality
* The reason for deprecating this function is the misleading name. The function checks
* if a given property (with a key) is attached to this item.
*/
bool HasKey(const std::string& key) const
#if defined(__GNUC__) && !defined(__CINT__)
__attribute__((deprecated))
#endif
;
/**
* HasProperty will return true if the property list contains a valid property with key
* @param key the property key
* @return true if key exists and property for key is valid
*/
bool HasProperty(const std::string& key) const;
/**
* HasProperty will return true if the property list contains a valid property with key
* @param key the property key
* @return true if key exists and property for key is valid
*/
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();
/**
* PropertyAsString will return the nth property as a string if printable
* @param key the property key
* @return nth property 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 property list
* @return all property keys
*/
std::string PropertyKeys() const;
/**
* PropertyCount will return the number of properties attached
* to this item. Attention!! Don't use the return value of this function for
* iteration over the properties. Use KeySize() instead.
* @return number of properties
*/
size_t PropertyCount() const;
/**
* This function is deprecated, use PropertyCount instead. The reason is, that
* XSize() functions in Reflex usually return the size of a container while this
* function now returns only the number of properties attached. The container it
* self can be larger, because it may have holes
*/
size_t PropertySize() const
#if defined(__GNUC__) && !defined(__CINT__)
__attribute__((deprecated))
#endif
;
/**
* PropertyValue will return the nth property value
* @param key the property key
* @return nth property 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 property value from the property list
* @param key of the property identified by the string
*/
void RemoveProperty(const std::string& key) const;
/**
* 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) const;
private:
/**
* the properties of the item
* @link aggregation
* @clentCardinality 1
* @supplierCardinality 0..1
* @label propertylist impl
*/
PropertyListImpl* fPropertyListImpl;
}; // class Propertylist
/**
* will put the property (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 PropertyList& p);
} //namespace Reflex
#include "Reflex/internal/PropertyListImpl.h"
//-------------------------------------------------------------------------------
inline
Reflex::PropertyList::operator bool() const {
//-------------------------------------------------------------------------------
return 0 != fPropertyListImpl;
}
//-------------------------------------------------------------------------------
inline Reflex::PropertyList::PropertyList(PropertyListImpl* propertyListImpl)
//-------------------------------------------------------------------------------
: fPropertyListImpl(propertyListImpl) {
}
//-------------------------------------------------------------------------------
inline Reflex::PropertyList::PropertyList(const PropertyList& pl)
//-------------------------------------------------------------------------------
: fPropertyListImpl(pl.fPropertyListImpl) {
}
//-------------------------------------------------------------------------------
inline Reflex::PropertyList::~PropertyList() {
//-------------------------------------------------------------------------------
}
//-------------------------------------------------------------------------------
inline
Reflex::PropertyList&
Reflex::PropertyList::operator=(const PropertyList& pl) {
//-------------------------------------------------------------------------------
if (&pl != this) {
fPropertyListImpl = pl.fPropertyListImpl;
}
return *this;
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::PropertyList::AddProperty(const std::string& key,
const Any& value) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->AddProperty(key, value);
}
return 0;
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyList::AddProperty(size_t key,
const Any& value) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->AddProperty(key, value);
}
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::PropertyList::AddProperty(const std::string& key,
const char* value) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->AddProperty(key, value);
}
return 0;
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyList::AddProperty(size_t key,
const char* value) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->AddProperty(key, value);
}
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyList::ClearProperties() const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
fPropertyListImpl->ClearProperties();
}
}
//-------------------------------------------------------------------------------
inline bool
Reflex::PropertyList::HasProperty(const std::string& key) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->HasProperty(key);
}
return false;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::PropertyList::HasProperty(size_t key) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->HasProperty(key);
}
return false;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::PropertyList::HasKey(const std::string& key) const {
//-------------------------------------------------------------------------------
return HasProperty(key);
}
//-------------------------------------------------------------------------------
inline std::string
Reflex::PropertyList::PropertyAsString(const std::string& key) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->PropertyAsString(key);
}
return "";
}
//-------------------------------------------------------------------------------
inline std::string
Reflex::PropertyList::PropertyAsString(size_t key) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->PropertyAsString(key);
}
return "";
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::PropertyList::PropertyKey(const std::string& key,
bool allocateNew) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->PropertyKey(key, allocateNew);
}
return 0;
}
//-------------------------------------------------------------------------------
inline std::string
Reflex::PropertyList::PropertyKeys() const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->PropertyKeys();
}
return "";
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::PropertyList::PropertyCount() const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
return fPropertyListImpl->PropertyCount();
}
return 0;
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::PropertyList::PropertySize() const {
//-------------------------------------------------------------------------------
return PropertyCount();
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyList::RemoveProperty(const std::string& key) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
fPropertyListImpl->RemoveProperty(key);
}
}
//-------------------------------------------------------------------------------
inline void
Reflex::PropertyList::RemoveProperty(size_t key) const {
//-------------------------------------------------------------------------------
if (fPropertyListImpl) {
fPropertyListImpl->RemoveProperty(key);
}
}
#endif // Reflex_PropertyList
|