[x265] [PATCH] dhdr: Skip comments in the json file while parsing it

Ashok Kumar Mishra ashok at multicorewareinc.com
Fri Feb 16 11:37:59 CET 2018


On Fri, Feb 16, 2018 at 1:51 PM, <bhavna at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Bhavna Hariharan <bhavna at multicorewareinc.com>
> # Date 1518761459 -19800
> #      Fri Feb 16 11:40:59 2018 +0530
> # Node ID d50bb9bf0ab29a5f15df83db1527b5337f2da9c1
> # Parent  a92fd62210b87f112f5fe087ede1a0e8f0eb8027
> dhdr: Skip comments in the json file while parsing it.
>
> Comments of the type /* */ OR // are ignored.
>
> diff -r a92fd62210b8 -r d50bb9bf0ab2 source/dynamicHDR10/JsonHelper.cpp
> --- a/source/dynamicHDR10/JsonHelper.cpp        Fri Feb 16 11:37:45 2018
> +0530
> +++ b/source/dynamicHDR10/JsonHelper.cpp        Fri Feb 16 11:40:59 2018
> +0530
> @@ -139,21 +139,13 @@
>          return JsonObject();
>      }
>
> -    ifstream tfile;
> -    string json_str;
> -    string json_str2;
> +    std::ifstream ifs(path);
> +    const std::string json_str2((std::istreambuf_iterator<char>(ifs)),
> +                                (std::istreambuf_iterator<char>()));
> +
>      string err = "";
> -    tfile.open(path);
> -    while(tfile)
> -    {
> -        std::getline(tfile, json_str);
> -        json_str2.append(json_str);
> -    }
>
> -    tfile.close();
> -    size_t beginning = json_str2.find_first_of("{");
> -    int fixchar = json_str2[json_str2.size() - 2] == '}' ? 1 : 0;
> -    return Json::parse(json_str2.substr(beginning,json_str2.size() -
> fixchar),err).object_items();
> +    return Json::parse(json_str2,err, JsonParse::COMMENTS).object_
> items();
>  }
>
>  JsonArray JsonHelper::readJsonArray(const string &path)
> @@ -174,28 +166,13 @@
>          return JsonArray();
>      }
>
> -    ifstream tfile;
> -    string json_str;
> -    string json_str2;
> +    std::ifstream ifs(path);
> +    const std::string json_str2((std::istreambuf_iterator<char>(ifs)),
> +                                (std::istreambuf_iterator<char>()));
> +
>      string err = "";
> -    tfile.open(path);
> -    while(tfile)
> -    {
> -        std::getline(tfile, json_str);
> -        json_str2.append(json_str);
> -    }
>
> -    tfile.close();
> -
> -    vector<Json> data;
> -    if (json_str2.size() != 0)
> -    {
> -        size_t beginning = json_str2.find_first_of("[");
> -        int fixchar = json_str2[json_str2.size() - 2] == ']' ? 1 : 0;
> -        return Json::parse(json_str2.substr(beginning, json_str2.size()
> - fixchar), err).array_items();
> -    }
> -    else
> -        return data;
> +    return Json::parse(json_str2,err, JsonParse::COMMENTS).array_items();
>  }
>
>  bool JsonHelper::validatePathExtension(string &path)
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
>
Pushed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20180216/580b17d2/attachment.html>


More information about the x265-devel mailing list