mirror of
https://github.com/Green-Sky/crdt_tests.git
synced 2025-12-07 03:16:34 +01:00
start refactoring to a lib version0
This commit is contained in:
31
version0/text_document.hpp
Normal file
31
version0/text_document.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "./list.hpp"
|
||||
|
||||
namespace GreenCRDT {
|
||||
|
||||
template<typename AgentType>
|
||||
struct TextDocument {
|
||||
// TODO: determine if char is the best
|
||||
using ListType = List<char, AgentType>;
|
||||
|
||||
struct Cursor {
|
||||
AgentType who;
|
||||
typename ListType::ListID pos;
|
||||
};
|
||||
|
||||
ListType state;
|
||||
|
||||
std::string getText(void) {
|
||||
std::string text;
|
||||
|
||||
for (const auto& it : state.list) {
|
||||
if (it.value) {
|
||||
text += it.value.value();
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
} // GreenCRDT
|
||||
|
||||
Reference in New Issue
Block a user