aboutsummaryrefslogtreecommitdiff
path: root/src/function/read_directory.h
AgeCommit message (Collapse)Author
2014-08-20Setting the correct work directory in FunctionExternalCommandAdrian Kummerlaender
* changed the XObjectValue constructor to accept a pointer to FilesystemContext instead of instantiating the context by itself * the FilesystemContext is now instantiated in the "callConstructDocument" member method of "FunctionBase" ** a const reference to FilesystemContext is passed to all "constructDocument" member method implementations * the FilesystemContext is currently only used by FunctionExternal command to set the correct work directory in "boost::process::context" ** this is required so calling external commands from inside a stylesheet works as expected *** i.e. from inside the directory the stylesheet is located in * modified all remaining external function implementations accordingly
2014-07-12Marked constructDocument member methods as constAdrian Kummerlaender
* they don't modifiy the class state so there is no reason for them not being marked as const ** all calling methods are also const ** this enables us to remove the const_cast in FunctionBase * modified external function implementations accordingly * inlined handleError method in FunctionTransform as it is not needed in multiple places anymore
2014-07-07Implemented custom xercesc::DOMDocument deleterAdrian Kummerlaender
* pointers to xercesc::DOMDocument were manually released ** this is now solved using a custom deleter for the appropriate std::unqiue_ptr template specialization * added matching factory method to DomDocumentCache * updated external function implementations accordingly ** "constructDocument" is now expected to return a DomDocumentCache::document_ptr instance * updated TransformerFacade accordingly * this change was implemented to get rid of the manual memory management required by xalan / xerces
2014-06-26Implemented basic external "write-file" functionAdrian Kummerlaender
* accepts a path parameter and the content to be written * removed target parameter form FunctionTransform ** transformation result is now returned as a string *** nodeset return value is planned ** e.g. writing the result to the fs is optional and has to be achieved using FunctionWriteFile * changed "transform" test case accordingly * this marks a paradigm shift and is the continuation of the changes described in 741a70f ** InputXSLT now also implements a output function * added basic io error handling to FunctionReadFile
2014-06-17Added context awareness to XObjectValue casting logicAdrian Kummerlaender
* added support for defining boost::filesystem::path as a external function parameter ** boost::filesystem::path parameters are resolved against the appropriate FilesystemContext and IncludeEntityResolver instances * xalan::XSLTInputSource parameter source paths are also resolved * removed need for passing a reference FilesystemContext to "constructDocument" methods ** they now only accept the parameters of the external function implemented by them ** all path resolution logic is wrapped by the newly created XObjectValue class * converted XObjectValue namespace into class ** the "get" template method is now a template member method ** this was needed to enable value casting logic to access the appropriate FilesystemContext and IncludeEntityResolver instances * this commit marks the next step towards the goals defined in 741a70f
2014-06-07Improved FunctionBase constructDocument parameter propagationAdrian Kummerländer
* replaced std::tuple constructing Mapper template methods with direct XObjectArgVectorType unpacking ** XObjectValue::get template method is applied directly using parameter pack unpacking * implemented custom IndexSequence / Sequence type to provide vector indexes * modified all external functions to provide matching constructDocument overloads
2014-05-17Equalized parameter/argument naming pattern accross all external functionsAdrian Kummerländer
* names matter, from now on parameters to external functions will be called parameters uniformly instead of mixing arguments and parameters
2014-05-15Adapted FunctionBase template to accept multiple argument typesAdrian Kummerländer
* FunctionBase::argument_tuple is a std::tuple specialization type specialized on the argument types passed inside the variadic template argument of FunctionBase * added tuple Mapper and XObjectValue helper namespaces containing recursive tuple construction and XObjectPtr value extraction logic * changed all external function implementations accordingly * this change was implemented to uniformly support different external function argument types than std::string
2014-05-14Added ArgumentCount parameter to FunctionBase templateAdrian Kummerländer
* constructDocument member method is provided with a FunctionBase::argument_array instance * improved argument validation in FunctionBase * this parameter was added to support FunctionBase as a base class for FunctionTransform
2014-05-09Marked DomDocumentCache::item class as privateAdrian Kummerländer
* as the xerces document is not instantiated by DomDocumentCache::item and the class only exports a pointer to the converted xalan document, it makes no sense to expose the class to the outside in the first place
2014-05-08Removed gtest based test cases and added program optionsAdrian Kummerländer
* selectively testing document construction in plain C++ code has turned out to be more work than worth it ** i.e. removed test cases and GTest dependency * added boost::program_options based frontent to InputXSLT ** example command: "./test --transformation ../dummy/transform.xsl --target out.xml" ** the plan is to use a simple shell script that generated test transformations and compares the output to reference files
2014-05-06Added basic external read file function test caseAdrian Kummerländer
* ... as a test of how well we are able to test DOM structures * required change of constructDocument visibility
2014-05-05Encapsulated common parts of external function inplementationsAdrian Kummerländer
* common parts were moved into CRTP template base class _FunctionBase_ * all external functions are derived from that class ** only have to implement _constructDocument_ member method ** currently only supports a single string input parameter which is enough for now * this change condenses external funtion implementations to the essential and should increase readability as well as maintainability
2014-05-02Changed external functions to enable global installationAdrian Kummerländer
* up until now all external functions were locally installed to a specific XalanTransformer instance contained within a TransformationGuard instance ** this had to change as I planned to add a "execute-transformation" function based on TransformationGuard which would have led to recursive self-instantiation ** global external functions have to be thread-safe * as global external function can not be provided with a reference to a transformation-specific FilesystemFacade instance, the working path is now determined using xalan::Locator ** currently using pointer arithmetics on XMLCh* to remove the "file://" prefix of the URI returned by locator->getSystemId(), may be unsafe * added compilation unit for PlattformGuard as it now contains function installation in addition to plattform lifetime management
2014-04-26Moved DomDocumentCache instances back into external function classAdrian Kummerländer
* A global DomDocumentCache instance would require key prefixing * switched internal data structure to std::unordered_map for average constant time access
2014-04-26Implemented global DOM document cacheAdrian Kummerländer
* the plan to return XML-nodes from each external function requires a better way to manage the lifetime of many xerces DOM document instances and their support class instances ** this is why DomDocumentCache and DomDocumentCache::item were implemented ** based on std::map so we can easily access the result of old function calls * changed external read-directory function to return the children of the document node instead of the document node itself ** removes unnecessary cruft in function calls ** will make returning status codes alongside the function result more pleasing to the eye * updated test transformation to reflect new features
2014-04-25Improved argument resolution and error handlingAdrian Kummerländer
* execute member method internal argument count checks are not needed when using between one and two arguments ** xalan automatically generates the appropriate message containing the getError message when only offered fixed argument execute member overloads * improved FunctionReadDirectory attribute element generation * added additional validations to FunctionReadFile and FunctionReadXMLFile * I plan to return errors inside a DOM tree alongside the function return values in the future
2014-04-23Fixed xerces DOM construction related memory leaksAdrian Kummerländer
* Wrapped xerces DOM and support class instances in now DomDocumentGuard scope-guard class * FunctionReadDirectory class contains interal std::stack instance to store DomDocumentGuard instances ** wrapped in std::shared_ptr as FunctionReadDirectory is internally cloned by xalan... ** this is needed as the DOM has to preserved longer than the external function execution scope * Sadly XMLCh xerces strings have to be manually released ** added appropriate xercesc::XMLString::release calls * xalan::XercesDOMWrapperParsedSource does not mirror a given xerces DOM but convert it on instantiation ** this is why there is a dedicated finalize member method in InputXSLT::DomDocumentGuard * In short: I do not like the amount of trickery needed to simply prevent memory leaks in this context ** there sadly doesn't seem to be a substantially easier way to return arbitrary DOM trees from a external function
2014-04-22Implemented basic XML output of external read-directory functionAdrian Kummerländer
* output is generated from XML hand-generated in a std::stringstream ** while this works reasonably well it is not how it should by done, i.e. this will have to be reimplemented using xerces / xalan constructs ** => this is intended to try out how a read-directory could work in a XSLT context
2014-04-21Implemented basic external directory traversal functionAdrian Kummerländer
* _read-directory_ lists all files in a given directory ** currently text-only output, xml planned * improved FilesystemContext path resolution (relative path is fully resolved by boost::filesystem)