You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.9 KiB

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