37 #define utils_debug_key "fojson"
43 for (
size_t i = 0; i < input.length(); ++i) {
44 if (
unsigned(input[i]) <
'\x20' || input[i] ==
'\\' || input[i] ==
'"') {
45 ss <<
"\\u" << std::setfill(
'0') << std::setw(4) << std::hex << unsigned(input[i]);
64 libdap::Array::Dim_iter dIt;
69 unsigned int dimSize = 1;
73 BESDEBUG(
utils_debug_key,
"fojson::computeConstrainedShape() - Array has " << a->dimensions(
true) <<
" dimensions."<< endl);
75 for(dIt = a->dim_begin() ; dIt!=a->dim_end() ;dIt++){
76 BESDEBUG(
utils_debug_key,
"fojson::computeConstrainedShape() - Processing dimension '" << a->dimension_name(dIt)<<
"'. (dim# "<< dimNum <<
")"<< endl);
77 start = a->dimension_start(dIt,
true);
78 stride = a->dimension_stride(dIt,
true);
79 stop = a->dimension_stop(dIt,
true);
80 BESDEBUG(
utils_debug_key,
"fojson::computeConstrainedShape() - start: " << start <<
" stride: " << stride <<
" stop: "<<stop<< endl);
82 dimSize = 1 + ( (stop - start) / stride);
85 (*shape)[dimNum++] = dimSize;
99 std::string backslash_escape(std::string source,
char char_to_escape){
100 std::string escaped_result = source;
101 if(source.find(char_to_escape) != string::npos ){
103 for(
size_t i=0; i< source.length() ; i++){
104 if(source[i] == char_to_escape){
105 escaped_result.insert( i + found++,
"\\");
109 return escaped_result;
long computeConstrainedShape(libdap::Array *a, std::vector< unsigned int > *shape)
Compute the constrained shape of the Array and return it in a vector.
std::string escape_for_json(const std::string &input)
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream