1 #ifndef _PROPERTIES_H_
2 #define _PROPERTIES_H_
3 
4 /*
5  * This program source code file is part of KICAD, a free EDA CAD application.
6  *
7  * Copyright (C) 2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
8  * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #include <string>
25 #include <map>
26 #include <utf8.h>
27 
28 
29 /**
30  * A name/value tuple with unique names and optional values.  The names
31  * may be iterated alphabetically.
32  */
33 class PROPERTIES : public std::map< std::string, UTF8 >
34 {
35 public:
Clear(const std::string & aProperty)36     bool Clear( const std::string& aProperty )
37     {
38         return erase( aProperty ) > 0;
39     }
40 
Exists(const std::string & aProperty)41     bool Exists( const std::string& aProperty ) const
42     {
43         return count( aProperty ) > 0;
44     }
45 
46     /**
47      * Fetch a property by \a aName and returns true if that property was found, else false.
48      * If not found, \a aFetchedValue is not touched.
49      *
50      * @param aName is the property or option to look for.
51      * @param aFetchedValue is where to put the value of the property if it exists and
52      *                      \a  aFetchedValue is not NULL.
53      * @return true if property is found, else false.
54      */
55     bool Value( const char* aName, UTF8* aFetchedValue = nullptr ) const;
56 };
57 
58 #endif  // _PROPERTIES_H_
59 
60 //  LocalWords:  aName aFetchedValue
61