Initia; coding of write. Sync
This commit is contained in:
parent
15f7b08d68
commit
a63b60bab7
@ -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
|
Skip Blank Lines options on containers will skip passing any blank
|
||||||
lines or line containing only whitespace to the output.
|
lines or line containing only whitespace to the output.
|
||||||
|
|
||||||
|
|
||||||
|
32
__write.cpp
Normal file
32
__write.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#include "__write.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "Expression.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
22
__write.h
Normal file
22
__write.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef __write_h__
|
||||||
|
#define __write_h__
|
||||||
|
|
||||||
|
#include "Tag.h"
|
||||||
|
#include "ZString.h"
|
||||||
|
#include "MString.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
namespace jet {
|
||||||
|
|
||||||
|
class __write : public Tag {
|
||||||
|
|
||||||
|
public:
|
||||||
|
__write(coreutils::ZString &in, coreutils::MString &parent, Global &global);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user