Ported the obj parser.
This commit is contained in:
@@ -30,12 +30,12 @@ assets::shader_source_store_iterator<Char>::shader_source_store_iterator(
|
||||
|
||||
template<typename Char>
|
||||
typename assets::shader_source_store_iterator<Char>::reference assets::shader_source_store_iterator<Char>::operator*() const {
|
||||
return dereference(std::index_sequence_for<Char>{});
|
||||
return dereference();
|
||||
}
|
||||
|
||||
template<typename Char>
|
||||
assets::shader_source_store_iterator<Char>& assets::shader_source_store_iterator<Char>::operator++() {
|
||||
adjust_offsets(std::index_sequence_for<Char>{}, 1);
|
||||
calc_offset(1);
|
||||
++m_index;
|
||||
return *this;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ assets::shader_source_store_iterator<Char> assets::shader_source_store_iterator<
|
||||
|
||||
template<typename Char>
|
||||
assets::shader_source_store_iterator<Char>& assets::shader_source_store_iterator<Char>::operator--() {
|
||||
adjust_offsets(std::index_sequence_for<Char>{}, -1);
|
||||
calc_offset(-1);
|
||||
--m_index;
|
||||
return *this;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ assets::shader_source_store_iterator<Char> assets::shader_source_store_iterator<
|
||||
template<typename Char>
|
||||
assets::shader_source_store_iterator<Char>& assets::shader_source_store_iterator<Char>::operator+=(const difference_type n)
|
||||
{
|
||||
adjust_offsets(std::index_sequence_for<Char>{}, n);
|
||||
calc_offset(n);
|
||||
m_index += n;
|
||||
return *this;
|
||||
}
|
||||
@@ -172,7 +172,7 @@ assets::shader_source_store_iterator<Char>::dereference() const
|
||||
);
|
||||
}
|
||||
|
||||
bool assets::shader_source_store::insert(const id_type id, const data_type& data)
|
||||
inline bool assets::shader_source_store::insert(const id_type id, const data_type& data)
|
||||
{
|
||||
auto lock = std::unique_lock{ m_mutex };
|
||||
|
||||
@@ -181,10 +181,21 @@ bool assets::shader_source_store::insert(const id_type id, const data_type& data
|
||||
return insert(result.first, id, data);
|
||||
}
|
||||
|
||||
inline std::pair<assets::shader_source_store::iterator, bool> assets::shader_source_store::find(id_type id)
|
||||
{
|
||||
auto lock = std::shared_lock{ m_mutex };
|
||||
|
||||
return unsafe_find(id);
|
||||
}
|
||||
|
||||
template<typename... Ts>
|
||||
bool assets::shader_source_store::insert(iterator it, const id_type id, const data_type& data)
|
||||
inline std::pair<assets::shader_source_store::const_iterator, bool> assets::shader_source_store::find(id_type id) const
|
||||
{
|
||||
auto lock = std::shared_lock{ m_mutex };
|
||||
|
||||
return unsafe_find(id);
|
||||
}
|
||||
|
||||
inline bool assets::shader_source_store::unsafe_insert(iterator it, const id_type id, const data_type& data)
|
||||
{
|
||||
auto lock = std::unique_lock{ m_mutex };
|
||||
|
||||
@@ -223,10 +234,8 @@ bool assets::shader_source_store::insert(iterator it, const id_type id, const da
|
||||
return new_entry;
|
||||
}
|
||||
|
||||
inline std::pair<assets::shader_source_store::iterator, bool> assets::shader_source_store::find(id_type id)
|
||||
inline std::pair<assets::shader_source_store::iterator, bool> assets::shader_source_store::unsafe_find(id_type id)
|
||||
{
|
||||
auto lock = std::shared_lock{ m_mutex };
|
||||
|
||||
const auto it = std::ranges::lower_bound(m_ids, id);
|
||||
|
||||
const auto found = it != m_ids.end() and *it == id;
|
||||
@@ -235,10 +244,8 @@ inline std::pair<assets::shader_source_store::iterator, bool> assets::shader_sou
|
||||
return { begin() + index, found };
|
||||
}
|
||||
|
||||
inline std::pair<assets::shader_source_store::const_iterator, bool> assets::shader_source_store::find(id_type id) const
|
||||
inline std::pair<assets::shader_source_store::const_iterator, bool> assets::shader_source_store::unsafe_find(id_type id) const
|
||||
{
|
||||
auto lock = std::shared_lock{ m_mutex };
|
||||
|
||||
const auto it = std::ranges::lower_bound(m_ids, id);
|
||||
|
||||
const auto found = it != m_ids.end() and *it == id;
|
||||
@@ -251,14 +258,16 @@ void assets::shader_source_store::remove(const iterator& it)
|
||||
{
|
||||
auto lock = std::unique_lock{ m_mutex };
|
||||
|
||||
m_ids.erase(m_ids.begin() + it.m_index);
|
||||
const auto index = it.m_index;
|
||||
|
||||
m_ids.erase(m_ids.begin() + index);
|
||||
|
||||
const auto strings_begin = m_strings.begin() + it.m_offset;
|
||||
const auto strings_end = begin + it.m_lengths[it.m_index] + sizeof('\0');
|
||||
const auto strings_end = strings_begin + it.m_lengths[it.m_index] + sizeof('\0');
|
||||
m_strings.erase(strings_begin, strings_end);
|
||||
|
||||
m_lengths.erase(m_lengths.begin() + it.m_index);
|
||||
m_metadata.erase(m_metadata.begin() + it.m_index);
|
||||
m_lengths.erase(m_lengths.begin() + index);
|
||||
m_metadata.erase(m_metadata.begin() + index);
|
||||
}
|
||||
|
||||
void assets::shader_source_store::clear()
|
||||
|
||||
Reference in New Issue
Block a user