aboutsummaryrefslogtreecommitdiff
path: root/src/function/read_directory.cc
AgeCommit message (Collapse)Author
2014-05-04Changed FilesystemContext constructor to accept xalan::Locator*Adrian Kummerländer
* all instantiations of a FilesystemContext are currently based on information provided by a xalan::Locator instance provided to the external function execute member method * this change hides the stylesheet path extraction from the actual function implementation
2014-05-03Revamped DomDocumentCache with regard to thread safetyAdrian Kummerländer
* DomDocumentCache::item class now is _finalized_ by default and doesn't perform document instantiation, just lifetime management ** xercesc::DOMDocument is instantiated inside the external function implementations and committed to the document cache for conversion to a xalan document * added mutex with scoped lock to prevent concurrent write access to the std::unordered_map contained withing DomDocumentCache * functionality of the _get_ member method was split into _get_ and _create_ ** added typedef for std::pair specialization type "optional_item" that functions as the return value of _create_ and _get_ * "locator->getSystemId()" was leaking memory as xerces doesn't manage the lifetime of the returned heap-allocated char array ** analog to XMLCh* strings ** transformed XercesStringGuard into template class to be instantiated on either XMLCh or char
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-30Moved file reading functionality into local functionsAdrian Kummerländer
* it was moved into functions local to the respective compilation unit to improve readability ** splits DOM tree construction logic from the actual purpose of the external function
2014-04-29Simplified external function result node setAdrian Kummerländer
* all functions return a single "error" node in the case that something went wrong * otherwise they return one or more "result" nodes that contain the function results and may be distinguished by one or more attributes * this makes handling the return values easier and more pleasing to the eye as not everything has to be prefixed by "self::*" * updated test transformation accordingly
2014-04-28Adapted read-directory tree construction to match the other functionsAdrian Kummerländer
* throwing std::out_of_range exception from DomDocumentCache::get instead of returning nullptr in case of a problem * moved xalanToString method back into FilesystemContext compilation unit as is only needed there
2014-04-27Added status information to external read-xml-file functionAdrian Kummerländer
* XML tree is contained below the _content_ node if read was successful ** status is set to error otherwise * updated test transformation accordingly
2014-04-26Added status information to external read-directory functionAdrian Kummerländer
* updated test transformation accordingly
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-24Added XercesStringGuard scope-guard to manage XMLChAdrian Kummerländer
* xercesc requires XMLCh* strings to be hand-allocated and released using the XMLString class * XercesStringGuard works as a scope-guard for XMLCh* string lifetime and greatly simplifies xerces DOM construction
2014-04-24Expanded FunctionReadDirectory class to return files and directoriesAdrian Kummerländer
* they are marked appropriately by a _type_ attribute
2014-04-24Changed TransformerFacade into TransformationFacade for single XSLTsAdrian Kummerländer
* contains a single, compiled transformation as specified by its construction argument * uses the transformation's location as the FilesystemContext * allows generation of output documents using _generate_ member method
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-23Switched read-directory nodeSet generation to a xerces DOM documentAdrian Kummerländer
* replacement for manual XML construction * currently leaks memory as the objects have to exist out of scope and I have not yet thought of how to best manage their lifetime
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)