mirror of
https://github.com/Green-Sky/crdt_tests.git
synced 2024-11-14 18:13:01 +01:00
34 lines
468 B
C++
34 lines
468 B
C++
#pragma once
|
|
|
|
#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
|
|
|