From c177d182376b88b337863e19f1df417b1ea07ff1 Mon Sep 17 00:00:00 2001
From: aheinri5 <Anna@netzkritzler.de>
Date: Wed, 18 Nov 2020 23:09:12 +0100
Subject: [PATCH] Moved functions to generate_functions

---
 R/analyse_xml.R | 88 +------------------------------------------------
 1 file changed, 1 insertion(+), 87 deletions(-)

diff --git a/R/analyse_xml.R b/R/analyse_xml.R
index f6e95fb..2f73b1d 100644
--- a/R/analyse_xml.R
+++ b/R/analyse_xml.R
@@ -189,95 +189,9 @@ analyse_xml <- function(path, pattern, element_name) {
 }
 
 
-#Experimental stuff
-generate_from_element <- function(element_name, attrs, children) {
-
-
-}
-
-generate_class_from_element <- function(element_name, class_name = NULL) {
-
-    #Generate name of new class from element name if class_name is not specified
-    if(is.null(class_name)){
-        class_name <- snakecase::to_any_case(element_name, "snake")
-    }
-
-
-    generated_class <- structure(list(), class = class_name)
-
-    return(generated_class)
-}
-
-generate_validator_from_element <- function() {
-
-}
-
-
-#cat(generate_as_node_from_element("DataArray", c("SexyAttr")))
-
-#'generate_as_node_from_element
-#'@description Generates a method for the generic function as_node based on an XML element
-#'@param element_name The name of the XML element to base the function on
-#'@param attrs Optional: A list of element attributes
-#'@param children Optional: A list of element children
-generate_as_node_from_element <- function(element_name,
-                                          attrs = NULL,
-                                          children = NULL) {
-
-    attrs_snake_names <- sapply(attrs, snakecase::to_any_case, case = "snake")
-    children_snake_names <- sapply(children, snakecase::to_any_case, case = "snake")
-
-    element_snake_name <- snakecase::to_any_case(element_name, "snake")
-
-    f_name <- paste0("as_node.", element_snake_name)
-
-    #Is the child a parent itself?
-    is_parent = TRUE
-
-    func_str <- paste0(f_name, " <- function(obj) {\n")
-
-    node_name <- paste0(element_snake_name, "_node")
-
-    func_str <- paste0(func_str, "\t", node_name, " <- list(", element_name," = structure(list())\n")
-
-    #Add attributes
-    for(i in seq_len(length(attrs))){
-        nattr <- attrs_snake_names[[i]]
-        attr <- attrs[[i]]
-
-        func_str <- paste0(func_str, "\t", node_name, " <- add_attr(", node_name,
-                               ", obj$", nattr, ", '", attr, "')\n")
-    }
-
-    #Add children
-    for(i in seq_len(length(children))){
-        child_snake <- children_snake_names[[i]]
-        child <- children[[i]]
-
-        #If a child is a parent, either call as_node or adopt_nodes
-        if(is_parent){
-            if(1){
-                func_str <- paste0(func_str, "\t", node_name, " <- add_child(", node_name,
-                               ", obj$", child_snake, ", '", child, "')\n")
-            }else{
-
-            }
-        }else{
-            func_str <- paste0(func_str, "\t", node_name, " <- add_child(", node_name,
-                               ", obj$", child_snake, ")\n")
-        }
-
-    }
-
-    func_str <- paste0(func_str, "\t", "return(", node_name, ")\n")
-
-    func_str <- paste0(func_str, "}")
-
-    return(invisible(func_str))
-}
-
 #============================== HELPERS FOR analyse_xml ================================
 
+
 #'get_required
 #'@description Helper function to mark required attributes or children from a vector of names and a
 #' vector of occurrence probabilities
-- 
GitLab