summaryrefslogtreecommitdiff
path: root/server/src/journalwriter.cc
diff options
context:
space:
mode:
authordeva <deva>2010-06-10 07:03:06 +0000
committerdeva <deva>2010-06-10 07:03:06 +0000
commit198b0d886817f2c5bc97cfd11857d4b314dffae3 (patch)
tree4fc2d51de46ab69b9e67149abf0ab6a332032f27 /server/src/journalwriter.cc
parent730eb796bbce6f124be9194f1565b7dda1daddf1 (diff)
Add transaction support on database pr. pracro session. Makes it possible to discard all edited macros.
Diffstat (limited to 'server/src/journalwriter.cc')
-rw-r--r--server/src/journalwriter.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/server/src/journalwriter.cc b/server/src/journalwriter.cc
index 4b2b4be..5858de4 100644
--- a/server/src/journalwriter.cc
+++ b/server/src/journalwriter.cc
@@ -217,7 +217,7 @@ void JournalWriter::addEntry(Transaction &transaction, Commit &commit,
void JournalWriter::addEntry(std::string resume, std::string macro, int index)
{
// Strip trailing whitespace, and add newlines.
- std::string r = stripTrailingWhitepace(addNewlines(resume, 60));
+ std::string r = resume;
std::string m = macro;
ResumeEntry re;
@@ -235,7 +235,7 @@ void JournalWriter::commit()
while(i != entrylist.end()) {
if(resume != "") resume += "\n\n";
// resume += i->macro + "\n";
- resume += i->second.resume;
+ resume += stripTrailingWhitepace(addNewlines(i->second.resume, 60));
i++;
}
@@ -247,6 +247,29 @@ void JournalWriter::commit()
resume.c_str(), resume.size());
}
+std::string JournalWriter::getEntry(std::string macro)
+{
+ std::map< int, ResumeEntry >::iterator i = entrylist.begin();
+ while(i != entrylist.end()) {
+ if(i->second.macro == macro) return i->second.resume;
+ i++;
+ }
+ return "";
+}
+
+void JournalWriter::removeEntry(std::string macro)
+{
+ std::map< int, ResumeEntry >::iterator i = entrylist.begin();
+ while(i != entrylist.end()) {
+ if(i->second.macro == macro) {
+ entrylist.erase(i);
+ break;
+ }
+ i++;
+ }
+}
+
+
#ifdef TEST_JOURNALWRITER
//deps: debug.cc journal_commit.cc
//cflags: -I..