Browse Source

initial commit

master
boB Rudis 5 years ago
parent
commit
2a312a4ae8
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      .Rbuildignore
  2. 17
      DESCRIPTION
  3. 2
      LICENSE
  4. 21
      LICENSE.md
  5. 7
      NAMESPACE
  6. 7
      R/RcppExports.R
  7. 24
      R/main.R
  8. 18
      R/plist-package.R
  9. 1
      README.Rmd
  10. 70
      README.md
  11. 9
      man/plist.Rd
  12. 14
      man/plist_to_list.Rd
  13. 14
      man/plist_to_xml.Rd
  14. 3
      src/.gitignore
  15. 3
      src/Makevars
  16. 28
      src/RcppExports.cpp
  17. 29
      src/main.cpp

1
.Rbuildignore

@ -19,3 +19,4 @@
^CRAN-RELEASE$
^appveyor\.yml$
^tools$
^LICENSE\.md$

17
DESCRIPTION

@ -1,6 +1,6 @@
Package: plist
Type: Package
Title: plist title goes here otherwise CRAN checks fail
Title: Read and Manipulate Binary or XML Property Lists
Version: 0.1.0
Date: 2019-10-22
Authors@R: c(
@ -8,17 +8,24 @@ Authors@R: c(
comment = c(ORCID = "0000-0001-5670-2640"))
)
Maintainer: Bob Rudis <bob@rud.is>
Description: A good description goes here otherwise CRAN checks fail.
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.
URL: https://gitlab.com/hrbrmstr/plist
BugReports: https://gitlab.com/hrbrmstr/plist/issues
Encoding: UTF-8
License: AGPL
License: MIT + file LICENSE
Suggests:
covr, tinytest
Depends:
R (>= 3.2.0)
Imports:
httr,
jsonlite
XML,
Rcpp
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
LinkingTo:
Rcpp

2
LICENSE

@ -0,0 +1,2 @@
YEAR: 2019
COPYRIGHT HOLDER: Bob Rudis

21
LICENSE.md

@ -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.

7
NAMESPACE

@ -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)

7
R/RcppExports.R

@ -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)
}

24
R/main.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)
}

18
R/plist-package.R

@ -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"

1
README.Rmd

@ -1,3 +1,4 @@
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: console

70
README.md

@ -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.

9
man/plist.Rd

@ -4,9 +4,14 @@
\name{plist}
\alias{plist}
\alias{plist-package}
\title{...}
\title{Read and Manipulate Binary or XML Property Lists}
\description{
A good description goes here otherwise CRAN checks fail.
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.
}
\seealso{
Useful links:

14
man/plist_to_list.Rd

@ -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
}

14
man/plist_to_xml.Rd

@ -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
}

3
src/.gitignore

@ -0,0 +1,3 @@
*.o
*.so
*.dll

3
src/Makevars

@ -0,0 +1,3 @@
CXX_STD = CXX11
PKG_CXXFLAGS =
PKG_LIBS = -L. -lplist

28
src/RcppExports.cpp

@ -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);
}

29
src/main.cpp

@ -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…
Cancel
Save