14 #ifndef smtk_attribute_FileSystemItem_h
15 #define smtk_attribute_FileSystemItem_h
17 #include "smtk/CoreExports.h"
19 #include "smtk/attribute/Item.h"
28 class FileSystemItemDefinition;
34 typedef std::vector<std::string>::const_iterator const_iterator;
40 bool shouldBeRelative()
const;
41 bool shouldExist()
const;
42 std::size_t numberOfValues()
const {
return m_values.size(); }
43 bool setNumberOfValues(std::size_t newSize);
44 std::size_t numberOfRequiredValues()
const;
45 bool isExtensible()
const;
46 std::size_t maxNumberOfValues()
const;
47 std::string value(std::size_t element = 0)
const {
return m_values[element]; }
48 bool setValue(
const std::string& val) {
return this->setValue(0, val); }
49 bool setValue(std::size_t element,
const std::string& val);
50 bool appendValue(
const std::string& val);
51 bool removeValue(std::size_t element);
52 void reset()
override;
53 virtual bool setToDefault(std::size_t elementIndex = 0);
55 virtual bool isUsingDefault(std::size_t elementIndex)
const;
57 virtual bool isUsingDefault()
const;
59 bool hasDefault()
const;
60 std::string defaultValue()
const;
61 virtual std::string valueAsString(
const std::string& format =
"")
const
63 return this->valueAsString(0, format);
65 virtual std::string valueAsString(std::size_t element,
const std::string& format =
"")
const;
66 virtual bool isSet(std::size_t element = 0)
const
68 return m_isSet.size() > element ? m_isSet[element] :
false;
71 virtual void unset(std::size_t element = 0)
73 assert(m_isSet.size() > element);
74 m_isSet[element] =
false;
78 const_iterator begin()
const;
79 const_iterator end()
const;
81 bool setValues(I vbegin, I vend, std::size_t offset = 0);
83 bool appendValues(I vbegin, I vend);
97 bool isValidInternal(
bool useCategories,
const std::set<std::string>& categories)
const override;
98 std::vector<std::string> m_values;
99 std::vector<bool> m_isSet;
105 bool FileSystemItem::setValues(I vbegin, I vend, std::size_t offset)
108 std::size_t num = vend - vbegin + offset;
109 if (this->setNumberOfValues(num))
113 for (I it = vbegin; it != vend; ++it, ++i)
115 if (!this->setValue(offset + i, *it))
129 bool FileSystemItem::appendValues(I vbegin, I vend)
131 return this->setValues(vbegin, vend, this->numberOfValues());