boB Rudis
5 years ago
17 changed files with 255 additions and 13 deletions
@ -0,0 +1,2 @@ |
|||
YEAR: 2019 |
|||
COPYRIGHT HOLDER: Bob Rudis |
@ -0,0 +1,21 @@ |
|||
# MIT License |
|||
|
|||
Copyright (c) 2019 Bob Rudis |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
SOFTWARE. |
@ -1,4 +1,7 @@ |
|||
# Generated by roxygen2: do not edit by hand |
|||
|
|||
import(httr) |
|||
importFrom(jsonlite,fromJSON) |
|||
export(plist_to_list) |
|||
export(plist_to_xml) |
|||
importFrom(Rcpp,sourceCpp) |
|||
importFrom(XML,readKeyValueDB) |
|||
useDynLib(plist, .registration = TRUE) |
|||
|
@ -0,0 +1,7 @@ |
|||
# Generated by using Rcpp::compileAttributes() -> do not edit by hand |
|||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 |
|||
|
|||
int_get_plist <- function(r) { |
|||
.Call(`_plist_int_get_plist`, r) |
|||
} |
|||
|
@ -0,0 +1,24 @@ |
|||
#' Convert a property list (binary or XML) to an R list |
|||
#' |
|||
#' @param x binary or XML property list |
|||
#' @export |
|||
plist_to_list <- function(x) { |
|||
|
|||
if (is.character(x)) x <- charToRaw(x) |
|||
|
|||
tmp <- int_get_plist(x) |
|||
XML::readKeyValueDB(tmp) |
|||
|
|||
} |
|||
|
|||
#' Convert a property list to raw (unparsed) XML |
|||
#' |
|||
#' @param x binary or XML property list |
|||
#' @export |
|||
plist_to_xml <- function(x) { |
|||
|
|||
if (is.character(x)) x <- charToRaw(x) |
|||
|
|||
int_get_plist(x) |
|||
|
|||
} |
@ -1,9 +1,19 @@ |
|||
#' ... |
|||
#' |
|||
#' Read and Manipulate Binary or XML Property Lists |
|||
#' |
|||
#' A property list is a representation of a hierarchy of objects that |
|||
#' can be stored in the file system, memory, or databases and reconstituted later. |
|||
#' Property lists give applications a lightweight and portable way to store small |
|||
#' amounts of data. They are hierarchies of data made from specific types of |
|||
#' objects—they are, in effect, an object graph. Tools are provided to read |
|||
#' and manipulate binary or XML property lists. |
|||
#' |
|||
#' @md |
|||
#' @name plist |
|||
#' @keywords internal |
|||
#' @author Bob Rudis (bob@@rud.is) |
|||
#' @import httr |
|||
#' @importFrom jsonlite fromJSON |
|||
#' @importFrom XML readKeyValueDB |
|||
## usethis namespace: start |
|||
#' @importFrom Rcpp sourceCpp |
|||
#' @useDynLib plist, .registration = TRUE |
|||
## usethis namespace: end |
|||
"_PACKAGE" |
|||
|
@ -0,0 +1,70 @@ |
|||
|
|||
[![Project Status: Active – The project has reached a stable, usable |
|||
state and is being actively |
|||
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) |
|||
[![Signed |
|||
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr) |
|||
![Signed commit |
|||
%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg) |
|||
[![Linux build |
|||
Status](https://travis-ci.org/hrbrmstr/plist.svg?branch=master)](https://travis-ci.org/hrbrmstr/plist) |
|||
![Minimal R |
|||
Version](https://img.shields.io/badge/R%3E%3D-3.2.0-blue.svg) |
|||
![License](https://img.shields.io/badge/License-MIT-blue.svg) |
|||
|
|||
# plist |
|||
|
|||
Read and Manipulate Binary or XML Property Lists |
|||
|
|||
## Description |
|||
|
|||
A property list is a representation of a hierarchy of objects that can |
|||
be stored in the file system, memory, or databases and reconstituted |
|||
later. Property lists give applications a lightweight and portable way |
|||
to store small amounts of data. They are hierarchies of data made from |
|||
specific types of objects—they are, in effect, an object graph. Tools |
|||
are provided to read and manipulate binary or XML property lists. |
|||
|
|||
## What’s Inside The Tin |
|||
|
|||
The following functions are implemented: |
|||
|
|||
- `plist_to_list`: Convert a property list (binary or XML) to an R |
|||
list |
|||
- `plist_to_xml`: Convert a property list to raw (unparsed) XML |
|||
|
|||
## Installation |
|||
|
|||
``` r |
|||
remotes::install_git("https://git.sr.ht/~hrbrmstr/plist") |
|||
# or |
|||
remotes::install_gitlab("hrbrmstr/plist") |
|||
``` |
|||
|
|||
NOTE: To use the ‘remotes’ install options you will need to have the |
|||
[{remotes} package](https://github.com/r-lib/remotes) installed. |
|||
|
|||
## Usage |
|||
|
|||
``` r |
|||
library(plist) |
|||
|
|||
# current version |
|||
packageVersion("plist") |
|||
## [1] '0.1.0' |
|||
``` |
|||
|
|||
## plist Metrics |
|||
|
|||
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) | |
|||
| :--- | -------: | ---: | --: | ---: | ----------: | ---: | -------: | ---: | |
|||
| HTML | 1 | 0.12 | 412 | 0.87 | 89 | 0.68 | 5 | 0.08 | |
|||
| C++ | 2 | 0.25 | 37 | 0.08 | 16 | 0.12 | 4 | 0.06 | |
|||
| R | 4 | 0.50 | 16 | 0.03 | 11 | 0.08 | 28 | 0.43 | |
|||
| Rmd | 1 | 0.12 | 8 | 0.02 | 15 | 0.11 | 28 | 0.43 | |
|||
|
|||
## Code of Conduct |
|||
|
|||
Please note that this project is released with a Contributor Code of |
|||
Conduct. By participating in this project you agree to abide by its |
|||
terms. |
@ -0,0 +1,14 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/main.R |
|||
\name{plist_to_list} |
|||
\alias{plist_to_list} |
|||
\title{Convert a property list (binary or XML) to an R list} |
|||
\usage{ |
|||
plist_to_list(x) |
|||
} |
|||
\arguments{ |
|||
\item{x}{binary or XML property list} |
|||
} |
|||
\description{ |
|||
Convert a property list (binary or XML) to an R list |
|||
} |
@ -0,0 +1,14 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/main.R |
|||
\name{plist_to_xml} |
|||
\alias{plist_to_xml} |
|||
\title{Convert a property list to raw (unparsed) XML} |
|||
\usage{ |
|||
plist_to_xml(x) |
|||
} |
|||
\arguments{ |
|||
\item{x}{binary or XML property list} |
|||
} |
|||
\description{ |
|||
Convert a property list to raw (unparsed) XML |
|||
} |
@ -0,0 +1,3 @@ |
|||
*.o |
|||
*.so |
|||
*.dll |
@ -0,0 +1,3 @@ |
|||
CXX_STD = CXX11 |
|||
PKG_CXXFLAGS = |
|||
PKG_LIBS = -L. -lplist |
@ -0,0 +1,28 @@ |
|||
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
|
|||
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
|
|||
|
|||
#include <Rcpp.h> |
|||
|
|||
using namespace Rcpp; |
|||
|
|||
// int_get_plist
|
|||
CharacterVector int_get_plist(RawVector r); |
|||
RcppExport SEXP _plist_int_get_plist(SEXP rSEXP) { |
|||
BEGIN_RCPP |
|||
Rcpp::RObject rcpp_result_gen; |
|||
Rcpp::RNGScope rcpp_rngScope_gen; |
|||
Rcpp::traits::input_parameter< RawVector >::type r(rSEXP); |
|||
rcpp_result_gen = Rcpp::wrap(int_get_plist(r)); |
|||
return rcpp_result_gen; |
|||
END_RCPP |
|||
} |
|||
|
|||
static const R_CallMethodDef CallEntries[] = { |
|||
{"_plist_int_get_plist", (DL_FUNC) &_plist_int_get_plist, 1}, |
|||
{NULL, NULL, 0} |
|||
}; |
|||
|
|||
RcppExport void R_init_plist(DllInfo *dll) { |
|||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); |
|||
R_useDynamicSymbols(dll, FALSE); |
|||
} |
@ -0,0 +1,29 @@ |
|||
#include <Rcpp.h> |
|||
#include "plist/plist.h" |
|||
|
|||
using namespace Rcpp; |
|||
|
|||
// [[Rcpp::export]]
|
|||
CharacterVector int_get_plist(RawVector r) { |
|||
|
|||
char *plist_out = NULL; |
|||
char *plist_entire = NULL; |
|||
|
|||
uint32_t read_size = r.size(); |
|||
uint32_t size = 0; |
|||
|
|||
plist_t root_node = NULL; |
|||
|
|||
plist_from_memory((char *)&r[0], read_size, &root_node); |
|||
plist_to_xml(root_node, &plist_out, &size); |
|||
|
|||
CharacterVector out(plist_out); |
|||
|
|||
plist_free(root_node); |
|||
|
|||
free(plist_entire); |
|||
free(plist_out); |
|||
|
|||
return(out); |
|||
|
|||
} |
Loading…
Reference in new issue