-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to dynamically add/remove static paths
- Loading branch information
Showing
10 changed files
with
260 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,57 @@ | ||
#include "utils.h" | ||
#include <iostream> | ||
#include <Rcpp.h> | ||
|
||
void trace(const std::string& msg) { | ||
#ifdef DEBUG_TRACE | ||
std::cerr << msg << std::endl; | ||
#endif | ||
} | ||
|
||
|
||
std::map<std::string, std::string> toStringMap(Rcpp::CharacterVector x) { | ||
ASSERT_MAIN_THREAD() | ||
|
||
std::map<std::string, std::string> strmap; | ||
|
||
if (x.size() == 0) { | ||
return strmap; | ||
} | ||
|
||
Rcpp::CharacterVector names = x.names(); | ||
if (names.isNULL()) { | ||
throw Rcpp::exception("Error converting CharacterVector to map<string, string>: vector does not have names."); | ||
} | ||
|
||
|
||
for (int i=0; i<x.size(); i++) { | ||
std::string name = Rcpp::as<std::string>(names[i]); | ||
std::string value = Rcpp::as<std::string>(x[i]); | ||
if (name == "") { | ||
throw Rcpp::exception("Error converting CharacterVector to map<string, string>: element has empty name."); | ||
} | ||
|
||
strmap.insert( | ||
std::pair<std::string, std::string>(name, value) | ||
); | ||
} | ||
|
||
return strmap; | ||
} | ||
|
||
|
||
Rcpp::CharacterVector toCharacterVector(const std::map<std::string, std::string>& strmap) { | ||
ASSERT_MAIN_THREAD() | ||
|
||
Rcpp::CharacterVector values(strmap.size()); | ||
Rcpp::CharacterVector names(strmap.size()); | ||
|
||
std::map<std::string, std::string>::const_iterator it = strmap.begin(); | ||
for (int i=0; it != strmap.end(); i++, it++) { | ||
values[i] = it->second; | ||
names[i] = it->first; | ||
} | ||
|
||
values.attr("names") = names; | ||
return values; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.