From a63b60bab7a153d3cc30d414d1764f604a5f6e3f Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Thu, 18 Jul 2024 16:34:11 -0700 Subject: [PATCH] Initia; coding of write. Sync --- JetCore.txt | 1 + __write.cpp | 32 ++++++++++++++++++++++++++++++++ __write.h | 22 ++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 __write.cpp create mode 100644 __write.h diff --git a/JetCore.txt b/JetCore.txt index 28095bd..1c4a393 100644 --- a/JetCore.txt +++ b/JetCore.txt @@ -11,3 +11,4 @@ itself is not passwed to the output and will not appear in the output. Skip Blank Lines options on containers will skip passing any blank lines or line containing only whitespace to the output. + diff --git a/__write.cpp b/__write.cpp new file mode 100644 index 0000000..9753ff5 --- /dev/null +++ b/__write.cpp @@ -0,0 +1,32 @@ +#include "__write.h" +#include "Exception.h" +#include "Expression.h" +#include + +namespace jet { + + __write::__set(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) { + output = false; + processContainer(container); + if(!variableDefined("file")) + throw coreutils::Exception("write tag must have file defined."); + if(!variableDefined("expr") && variableDefined("value") && hasContainer) + throw coreutils::Exception("write tag cannot have both value and a container."); + if(variableDefined("expr") && !variableDefined("value") && hasContainer) + throw coreutils::Exception("write tag cannot have both expr and a container."); + if(variableDefined("expr") && variableDefined("value") && !hasContainer) + throw coreutils::Exception("write tag cannot have both expr and value."); + if(!variableDefined("expr") && !variableDefined("value") && !hasContainer) + throw coreutils::Exception("write tag must have a value, expr or a container."); + if(variableDefined("scope")) + throw coreutils::Exception("Cannot use scope with write tag."); + + + int fd = open(variables["file"], O_APPEND | O_TRUNC); // <--- options go here need to pick one + + + + close(fd); + + } +} diff --git a/__write.h b/__write.h new file mode 100644 index 0000000..7583ddf --- /dev/null +++ b/__write.h @@ -0,0 +1,22 @@ +#ifndef __write_h__ +#define __write_h__ + +#include "Tag.h" +#include "ZString.h" +#include "MString.h" +#include + +namespace jet { + + class __write : public Tag { + + public: + __write(coreutils::ZString &in, coreutils::MString &parent, Global &global); + + protected: + + }; + +} + +#endif