2
nexml_env = new.env(hash=TRUE)
4
# If no prefix is given, will use a UUID
5
# Generates an id number by appending a counter to the prefix
6
# Will keep track of the counter for each prefix for that session.
8
nexml_id <- function(prefix = "",
9
use_uuid = getOption("uuid", FALSE)){
11
uid <- paste0("uuid-", UUIDgenerate())
13
if((prefix %in% ls(envir=nexml_env)))
14
id_counter <- get(prefix, envir=nexml_env)
16
assign(prefix, 1, envir=nexml_env)
20
uid <- paste0(prefix, id_counter)
21
id_counter <- id_counter + 1
22
assign(prefix, id_counter, envir=nexml_env)
29
#' reset the id counter
31
reset_id_counter <- function(){
32
rm(list=ls(envir=nexml_env), envir=nexml_env)
35
# use an environment to store counter