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.

67 lines
1.6 KiB

  1. /*
  2. ISC License
  3. Copyright (c) 2018, Antonio SJ Musumeci <trapexit@spawn.link>
  4. Permission to use, copy, modify, and/or distribute this software for any
  5. purpose with or without fee is hereby granted, provided that the above
  6. copyright notice and this permission notice appear in all copies.
  7. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. */
  15. #pragma once
  16. #include "nonstd/optional.hpp"
  17. #include "strvec.hpp"
  18. #include "tofrom_string.hpp"
  19. #include <cstdint>
  20. #include <string>
  21. #include <vector>
  22. class Branch final : public ToFromString
  23. {
  24. public:
  25. typedef std::vector<Branch> Vector;
  26. public:
  27. Branch(const uint64_t &default_minfreespace_);
  28. public:
  29. enum class Mode
  30. {
  31. INVALID,
  32. RO,
  33. RW,
  34. NC
  35. };
  36. public:
  37. bool ro(void) const;
  38. bool nc(void) const;
  39. bool ro_or_nc(void) const;
  40. public:
  41. int from_string(const std::string &str) final;
  42. std::string to_string(void) const final;
  43. public:
  44. uint64_t minfreespace() const;
  45. void set_minfreespace(const uint64_t);
  46. public:
  47. Mode mode;
  48. std::string path;
  49. private:
  50. nonstd::optional<uint64_t> _minfreespace;
  51. const uint64_t *_default_minfreespace;
  52. };