ctkPluginFrameworkUtil_p.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKPLUGINFRAMEWORKUTIL_P_H
  16. #define CTKPLUGINFRAMEWORKUTIL_P_H
  17. #include <QMap>
  18. #include <QStringList>
  19. #include <QDir>
  20. class ctkPluginFrameworkContext;
  21. /**
  22. * \ingroup PluginFramework
  23. */
  24. class ctkPluginFrameworkUtil
  25. {
  26. public:
  27. /**
  28. * Parse strings of format:
  29. *
  30. * ENTRY (, ENTRY)*
  31. * ENTRY = key (; key)* (; PARAM)*
  32. * PARAM = attribute '=' value
  33. * PARAM = directive ':=' value
  34. *
  35. * @param a Attribute being parsed
  36. * @param s String to parse
  37. * @param single If true, only allow one key per ENTRY
  38. * @param unique Only allow unique parameters for each ENTRY.
  39. * @param single_entry If true, only allow one ENTRY is allowed.
  40. * @return QMap<QString, QString> mapping attributes to values.
  41. * @exception std::invalid_argument If syntax error in input string.
  42. */
  43. static QList<QMap<QString, QStringList> > parseEntries(const QString& a, const QString& s,
  44. bool single, bool unique, bool single_entry);
  45. static QString getFrameworkDir(ctkPluginFrameworkContext* ctx);
  46. /**
  47. * Check for local file storage directory.
  48. *
  49. * @param name local directory name.
  50. * @return A QDir object pointing to the directory. The directory is
  51. * guaranteed to exist.
  52. * @throws std::runtime_error if there is no global framework storage
  53. * directory or if the directory could not be created.
  54. */
  55. static QDir getFileStorage(ctkPluginFrameworkContext* ctx, const QString& name);
  56. /**
  57. * Remove a non-empty directory.
  58. *
  59. * @param dirName The directory to remove
  60. * @returns <code>true</code> on success, <code>false</code> otherwise.
  61. */
  62. static bool removeDir(const QString& dirName);
  63. };
  64. #endif // CTKPLUGINFRAMEWORKUTIL_P_H