From fa8059760874fa98e62cad8eec09716a18ade0a1 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 19 Sep 2017 21:38:38 +0200 Subject: [PATCH 1/6] helpers.cpp: Add new functions - readFile() - parseJsonFromFile() - parseJsonFromString() parseJsonFromString() and parseJsonFromFile() use Json::CharReader instead of the obsolete function Json::Reader Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/05d8ed4105e8da783645d9985bd0de4eaf8a5bc8 Author: Michael Liebmann Date: 2017-09-19 (Tue, 19 Sep 2017) Origin message was: ------------------ helpers.cpp: Add new functions - readFile() - parseJsonFromFile() - parseJsonFromString() parseJsonFromString() and parseJsonFromFile() use Json::CharReader instead of the obsolete function Json::Reader ------------------ This commit was generated by Migit --- src/system/helpers-json.h | 31 ++++++++++++++++++++++++ src/system/helpers.cpp | 50 +++++++++++++++++++++++++++++++++++++++ src/system/helpers.h | 2 ++ 3 files changed, 83 insertions(+) create mode 100644 src/system/helpers-json.h diff --git a/src/system/helpers-json.h b/src/system/helpers-json.h new file mode 100644 index 000000000..0e4923649 --- /dev/null +++ b/src/system/helpers-json.h @@ -0,0 +1,31 @@ +#ifndef __system_helpers_json__ +#define __system_helpers_json__ + +/* + Neutrino-HD + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include + +using namespace std; + +bool parseJsonFromFile(string& jFile, Json::Value *root, string *errMsg); +bool parseJsonFromString(string& jData, Json::Value *root, string *errMsg); + +#endif diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index cc0f01325..d47485a62 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include "debug.h" @@ -49,6 +50,7 @@ #include //#include #include +#include #include #include #define MD5_DIGEST_LENGTH 16 @@ -1445,3 +1447,51 @@ string readLink(string lnk) return ""; } + +string readFile(string file) +{ + string ret_s; + ifstream tmpData(file.c_str(), ifstream::binary); + if (tmpData.is_open()) { + tmpData.seekg(0, tmpData.end); + int length = tmpData.tellg(); + tmpData.seekg(0, tmpData.beg); + char* buffer = new char[length+1]; + tmpData.read(buffer, length); + tmpData.close(); + buffer[length] = '\0'; + ret_s = (string)buffer; + delete [] buffer; + } + else { + cerr << "Error read " << file << endl; + return ""; + } + + return ret_s; +} + +bool parseJsonFromFile(string& jFile, Json::Value *root, string *errMsg) +{ + string jData = readFile(jFile); + bool ret = parseJsonFromString(jData, root, errMsg); + jData.clear(); + return ret; +} + +bool parseJsonFromString(string& jData, Json::Value *root, string *errMsg) +{ + Json::CharReaderBuilder builder; + Json::CharReader* reader(builder.newCharReader()); + JSONCPP_STRING errs = ""; + const char* jData_c = jData.c_str(); + + bool ret = reader->parse(jData_c, jData_c + strlen(jData_c), root, &errs); + if (!ret || (!errs.empty())) { + ret = false; + if (errMsg != NULL) + *errMsg = errs; + } + delete reader; + return ret; +} diff --git a/src/system/helpers.h b/src/system/helpers.h index 7bd7afb2d..910f9ea3c 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -152,4 +152,6 @@ std::string filehash(const char * file); std::string get_path(const char * path); inline bool file_exists(const std::string file) { return file_exists(file.c_str()); } +std::string readFile(std::string file); + #endif From 54b43f77450345497a3074fda6336d305b1b2541 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Tue, 19 Sep 2017 21:39:59 +0200 Subject: [PATCH 2/6] Use parseJsonFromString() for parsing json data in - CMoviePlayerGui::luaGetUrl() - CTimerList::RemoteBoxChanExists() - CTimerList::RemoteBoxTimerList() - CTimerList::paintItem() - cTmdb::GetMovieDetails() - cYTFeedParser::parseFeedJSON() - cYTFeedParser::parseFeedDetailsJSON() Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/25ae9295231f1bcdb6c1819eec93b1feb2626685 Author: Michael Liebmann Date: 2017-09-19 (Tue, 19 Sep 2017) Origin message was: ------------------ Use parseJsonFromString() for parsing json data in - CMoviePlayerGui::luaGetUrl() - CTimerList::RemoteBoxChanExists() - CTimerList::RemoteBoxTimerList() - CTimerList::paintItem() - cTmdb::GetMovieDetails() - cYTFeedParser::parseFeedJSON() - cYTFeedParser::parseFeedDetailsJSON() ------------------ This commit was generated by Migit --- src/gui/movieplayer.cpp | 9 +++++---- src/gui/timerlist.cpp | 28 +++++++++++++--------------- src/gui/tmdb.cpp | 16 +++++++++------- src/system/ytparser.cpp | 16 +++++++++------- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 22f7d892c..ab5b69b3f 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include @@ -814,12 +815,12 @@ bool CMoviePlayerGui::luaGetUrl(const std::string &script, const std::string &fi return false; } + string errMsg = ""; Json::Value root; - Json::Reader reader; - bool parsedSuccess = reader.parse(result_string, root, false); - if (!parsedSuccess) { + bool ok = parseJsonFromString(result_string, &root, &errMsg); + if (!ok) { printf("Failed to parse JSON\n"); - printf("%s\n", reader.getFormattedErrorMessages().c_str()); + printf("%s\n", errMsg.c_str()); if (box != NULL) { box->hide(); delete box; diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index a0e33df98..4d2baf318 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -69,6 +69,7 @@ #include #include #include +#include #include #include @@ -738,16 +739,15 @@ bool CTimerList::RemoteBoxChanExists(t_channel_id channel_id) r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); + string errMsg = ""; Json::Value root; - Json::Reader reader; - bool parsedSuccess = reader.parse(r_url, root, false); - if (!parsedSuccess) { + bool ok = parseJsonFromString(r_url, &root, &errMsg); + if (!ok) { printf("Failed to parse JSON\n"); - printf("%s\n", reader.getFormattedErrorMessages().c_str()); + printf("%s\n", errMsg.c_str()); } r_url = root.get("success","false").asString(); - if (r_url == "false") ShowMsg(LOCALE_REMOTEBOX_CHANNEL_NA, convertChannelId2String(channel_id), CMsgBox::mbrOk, CMsgBox::mbOk, NULL, 450, 30, false); @@ -796,13 +796,12 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); //printf("[remotetimer] timers:%s\n",r_url.c_str()); + string errMsg = ""; Json::Value root; - Json::Reader reader; - bool parsedSuccess = reader.parse(r_url, root, false); - if (!parsedSuccess) - { + bool ok = parseJsonFromString(r_url, &root, &errMsg); + if (!ok) { printf("Failed to parse JSON\n"); - printf("%s\n", reader.getFormattedErrorMessages().c_str()); + printf("%s\n", errMsg.c_str()); it->online = false; } else it->online = true; @@ -1286,13 +1285,12 @@ void CTimerList::paintItem(int pos) r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer.channel_id); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); + string errMsg = ""; Json::Value root; - Json::Reader reader; - bool parsedSuccess = reader.parse(r_url, root, false); - if (!parsedSuccess) - { + bool ok = parseJsonFromString(r_url, &root, &errMsg); + if (!ok) { printf("Failed to parse JSON\n"); - printf("%s\n", reader.getFormattedErrorMessages().c_str()); + printf("%s\n", errMsg.c_str()); } Json::Value remotechannel = root["data"]["channel"][0]; diff --git a/src/gui/tmdb.cpp b/src/gui/tmdb.cpp index 8ebe101c1..5a8208e27 100644 --- a/src/gui/tmdb.cpp +++ b/src/gui/tmdb.cpp @@ -35,6 +35,7 @@ #include "system/settings.h" #include "system/helpers.h" +#include #include "system/set_threadname.h" #include "gui/widget/hintbox.h" @@ -197,12 +198,12 @@ bool cTmdb::GetMovieDetails(std::string lang) if (!getUrl(url, answer)) return false; + string errMsg = ""; Json::Value root; - Json::Reader reader; - bool parsedSuccess = reader.parse(answer, root, false); - if (!parsedSuccess) { + bool ok = parseJsonFromString(answer, &root, &errMsg); + if (!ok) { printf("Failed to parse JSON\n"); - printf("%s\n", reader.getFormattedErrorMessages().c_str()); + printf("%s\n", errMsg.c_str()); return false; } @@ -219,10 +220,11 @@ bool cTmdb::GetMovieDetails(std::string lang) answer.clear(); if (!getUrl(url, answer)) return false; - parsedSuccess = reader.parse(answer, root, false); - if (!parsedSuccess) { + + ok = parseJsonFromString(answer, &root, &errMsg); + if (!ok) { printf("Failed to parse JSON\n"); - printf("%s\n", reader.getFormattedErrorMessages().c_str()); + printf("%s\n", errMsg.c_str()); return false; } diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index 407d452a4..6bd43c576 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -38,6 +38,7 @@ #include #include "settings.h" #include "helpers.h" +#include "helpers-json.h" #include "set_threadname.h" #include #include @@ -288,25 +289,25 @@ std::string cYTFeedParser::getXmlData(xmlNodePtr node) bool cYTFeedParser::parseFeedJSON(std::string &answer) { + string errMsg = ""; Json::Value root; - Json::Reader reader; std::ostringstream ss; std::ifstream fh(curfeedfile.c_str(),std::ifstream::in); ss << fh.rdbuf(); std::string filedata = ss.str(); - bool parsedSuccess = reader.parse(filedata,root,false); + bool parsedSuccess = parseJsonFromString(filedata, &root, NULL); if(!parsedSuccess) { - parsedSuccess = reader.parse(answer,root,false); + parsedSuccess = parseJsonFromString(answer, &root, &errMsg); } if(!parsedSuccess) { printf("Failed to parse JSON\n"); - printf("%s\n", reader.getFormattedErrorMessages().c_str()); + printf("%s\n", errMsg.c_str()); return false; } @@ -383,15 +384,16 @@ bool cYTFeedParser::parseFeedDetailsJSON(cYTVideoInfo* vinfo) if (!getUrl(url, answer)) return false; + string errMsg = ""; Json::Value root; - Json::Reader reader; - bool parsedSuccess = reader.parse(answer, root, false); + bool parsedSuccess = parseJsonFromString(answer, &root, &errMsg); if (!parsedSuccess) { printf("Failed to parse JSON\n"); - printf("%s\n", reader.getFormattedErrorMessages().c_str()); + printf("%s\n", errMsg.c_str()); return false; } + Json::Value elements = root["items"]; std::string duration = elements[0]["contentDetails"].get("duration", "").asString(); if (duration.find("PT") != std::string::npos) { From 049633bc07726fc7b8bcaa95173688a4c01b9751 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Wed, 20 Sep 2017 18:07:05 +0200 Subject: [PATCH 3/6] src/gui/osd_setup.cpp disable hint paint in channellist-mode, is broken Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/e308407b229b72cf2f1851a122221878114033d1 Author: Jacek Jendrzej Date: 2017-09-20 (Wed, 20 Sep 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/osd_setup.cpp | 27 +++++++++++++++++---------- src/gui/osd_setup.h | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 736c7f417..e6a97527c 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -1230,7 +1230,7 @@ void COsdSetup::showOsdInfobarSetup(CMenuWidget *menu_infobar) } //channellist -void COsdSetup::showOsdChanlistSetup(CMenuWidget *menu_chanlist) +void COsdSetup::showOsdChanlistSetup(CMenuWidget *menu_chanlist, bool hint_paint) { CMenuOptionChooser * mc; @@ -1239,38 +1239,45 @@ void COsdSetup::showOsdChanlistSetup(CMenuWidget *menu_chanlist) // channellist additional mc = new CMenuOptionChooser(LOCALE_CHANNELLIST_ADDITIONAL, &g_settings.channellist_additional, CHANNELLIST_ADDITIONAL_OPTIONS, CHANNELLIST_ADDITIONAL_OPTION_COUNT, true); - mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_ADDITIONAL); + if(hint_paint) + mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_ADDITIONAL); menu_chanlist->addItem(mc); // epg align mc = new CMenuOptionChooser(LOCALE_MISCSETTINGS_CHANNELLIST_EPGTEXT_ALIGN, &g_settings.channellist_epgtext_align_right, CHANNELLIST_EPGTEXT_ALIGN_RIGHT_OPTIONS, CHANNELLIST_EPGTEXT_ALIGN_RIGHT_OPTIONS_COUNT, true); - mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_EPG_ALIGN); + if(hint_paint) + mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_EPG_ALIGN); menu_chanlist->addItem(mc); // extended channel list mc = new CMenuOptionChooser(LOCALE_CHANNELLIST_EXTENDED, &g_settings.theme.progressbar_design_channellist, PROGRESSBAR_COLOR_OPTIONS, PROGRESSBAR_COLOR_OPTION_COUNT, true, this); - mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_EXTENDED); + if(hint_paint) + mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_EXTENDED); menu_chanlist->addItem(mc); // show infobox mc = new CMenuOptionChooser(LOCALE_CHANNELLIST_SHOW_INFOBOX, &g_settings.channellist_show_infobox, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, channellistNotifier); - mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_SHOW_INFOBOX); + if(hint_paint) + mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_SHOW_INFOBOX); menu_chanlist->addItem(mc); // foot mc = new CMenuOptionChooser(LOCALE_CHANNELLIST_FOOT, &g_settings.channellist_foot, CHANNELLIST_FOOT_OPTIONS, CHANNELLIST_FOOT_OPTIONS_COUNT, g_settings.channellist_show_infobox); - mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_FOOT); + if(hint_paint) + mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_FOOT); menu_chanlist->addItem(mc); channellistNotifier->addItem(mc); //show channel logo mc = new CMenuOptionChooser(LOCALE_CHANNELLIST_SHOW_CHANNELLOGO, &g_settings.channellist_show_channellogo, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); - mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_SHOW_CHANNELLOGO); + if(hint_paint) + mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_SHOW_CHANNELLOGO); menu_chanlist->addItem(mc); //show numbers mc = new CMenuOptionChooser(LOCALE_CHANNELLIST_SHOW_CHANNELNUMBER, &g_settings.channellist_show_numbers, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); - mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_SHOW_CHANNELNUMBER); + if(hint_paint) + mc->setHint("", LOCALE_MENU_HINT_CHANNELLIST_SHOW_CHANNELNUMBER); menu_chanlist->addItem(mc); } @@ -1493,7 +1500,7 @@ int COsdSetup::showContextChanlistMenu(CChannelList *parent_channellist) menu_chanlist->enableFade(false); menu_chanlist->setSelected(cselected); - showOsdChanlistSetup(menu_chanlist); + showOsdChanlistSetup(menu_chanlist, false); menu_chanlist->addItem(new CMenuSeparator(CMenuSeparator::LINE)); CMenuWidget *fontSettingsSubMenu = new CMenuWidget(LOCALE_FONTMENU_HEAD, NEUTRINO_ICON_KEYBINDING); @@ -1511,7 +1518,7 @@ int COsdSetup::showContextChanlistMenu(CChannelList *parent_channellist) fontSettingsSubMenu->addItem(new CMenuForwarder(LOCALE_OPTIONS_DEFAULT, true, NULL, this, font_sizes_groups[i].actionkey)); CMenuForwarder * mf = new CMenuDForwarder(LOCALE_FONTMENU_HEAD, true, NULL, fontSettingsSubMenu, NULL, CRCInput::RC_red); - mf->setHint("", LOCALE_MENU_HINT_FONTS); +// mf->setHint("", LOCALE_MENU_HINT_FONTS);//FIXME menu restoreScreen menu_chanlist->addItem(mf); int res = menu_chanlist->exec(NULL, ""); diff --git a/src/gui/osd_setup.h b/src/gui/osd_setup.h index cdea56535..dbaaa2451 100644 --- a/src/gui/osd_setup.h +++ b/src/gui/osd_setup.h @@ -71,7 +71,7 @@ class COsdSetup : public CMenuTarget, public CChangeObserver void showOsdTimeoutSetup(CMenuWidget *menu_timeout); void showOsdMenusSetup(CMenuWidget *menu_menus); void showOsdInfobarSetup(CMenuWidget *menu_infobar); - void showOsdChanlistSetup(CMenuWidget *menu_chanlist); + void showOsdChanlistSetup(CMenuWidget *menu_chanlist, bool hint_paint = true); void showOsdEventlistSetup(CMenuWidget *menu_eventlist); void showOsdVolumeSetup(CMenuWidget *menu_volume); void showOsdInfoclockSetup(CMenuWidget *menu_infoclock); From 0a8ce310bed9dfa93a4d68ae54c28f4187539af3 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Wed, 20 Sep 2017 17:32:18 +0200 Subject: [PATCH 4/6] CComponentsFrmClock: Using less chars for time string. Current count of chars could be not enough in some cases. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ecdc1acb9fbbf6f576209b3d4b03bfe7749554f1 Author: Thilo Graf Date: 2017-09-20 (Wed, 20 Sep 2017) ------------------ This commit was generated by Migit --- src/gui/components/cc_frm_clock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index 4595edd58..590353478 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -58,7 +58,7 @@ class CComponentsFrmClock : public CComponentsForm, public CCTextScreen int cl_interval; ///raw time chars - char cl_timestr[20]; + char cl_timestr[32]; ///handle paint clock within thread and is not similar to cc_allow_paint bool paintClock; From bdbe2f5ab89dfece12b2bc5e4d4d4b7711c0437c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 20 Sep 2017 13:46:31 +0200 Subject: [PATCH 5/6] add and use FRAME_WIDTH defines; ... replace other fixed frame widths with OFFSET defines Signed-off-by: Thilo Graf Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/6ee3e54741400131c173e16c0b10c50618ddca14 Author: vanhofen Date: 2017-09-20 (Wed, 20 Sep 2017) Origin message was: ------------------ - add and use FRAME_WIDTH defines; ... replace other fixed frame widths with OFFSET defines Signed-off-by: Thilo Graf ------------------ This commit was generated by Migit --- src/gui/audioplayer.cpp | 2 +- src/gui/bedit/bouqueteditor_channels.cpp | 2 +- src/gui/bedit/bouqueteditor_chanselect.cpp | 2 +- src/gui/channellist.cpp | 6 +++--- src/gui/components/cc_frm_scrollbar.cpp | 2 +- src/gui/components/cc_item_progressbar.cpp | 2 +- src/gui/infoviewer.cpp | 2 +- src/gui/infoviewer_bb.cpp | 2 +- src/gui/osd_setup.cpp | 2 +- src/gui/volumebar.cpp | 2 +- src/gui/widget/colorchooser.cpp | 2 +- src/gui/widget/menue.cpp | 4 ++-- src/gui/widget/msgbox.cpp | 2 +- src/gui/widget/progresswindow.cpp | 2 +- src/system/settings.h | 1 + 15 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 99b9ccb57..ff0a572d0 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -1855,7 +1855,7 @@ void CAudioPlayerGui::paintDetailsLine(int pos) if (m_infobox == NULL) { m_infobox = new CComponentsInfoBox(m_x, ypos2, m_width, m_info_height); - m_infobox->setFrameThickness(2); + m_infobox->setFrameThickness(FRAME_WIDTH_MIN); m_infobox->setCorner(RADIUS_LARGE); m_infobox->setColorFrame(COL_FRAME_PLUS_0); m_infobox->setColorBody(COL_MENUCONTENTDARK_PLUS_0); diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 1b405ae83..d8532bd1d 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -246,7 +246,7 @@ void CBEChannelWidget::initItem2DetailsLine (int pos, int /*ch_index*/) ibox->hide(); ibox->setDimensionsAll(x, ypos2, width, info_height); - ibox->setFrameThickness(2); + ibox->setFrameThickness(FRAME_WIDTH_MIN); #if 0 ibox->paint(false,true); #endif diff --git a/src/gui/bedit/bouqueteditor_chanselect.cpp b/src/gui/bedit/bouqueteditor_chanselect.cpp index e9ee12385..e02c467c0 100644 --- a/src/gui/bedit/bouqueteditor_chanselect.cpp +++ b/src/gui/bedit/bouqueteditor_chanselect.cpp @@ -307,7 +307,7 @@ void CBEChannelSelectWidget::initItem2DetailsLine (int pos, int /*ch_index*/) //infobox if (ibox){ ibox->setDimensionsAll(x, ypos2, width, info_height); - ibox->setFrameThickness(2); + ibox->setFrameThickness(FRAME_WIDTH_MIN); ibox->setCorner(RADIUS_LARGE); ibox->disableShadow(); } diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 0672956d9..f3d9cca38 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -2011,11 +2011,11 @@ void CChannelList::paintItem(int pos, const bool firstpaint) pb.setDesign(g_settings.theme.progressbar_design_channellist); pb.setCornerType(0); pb.setStatusColors(COL_MENUCONTENT_PLUS_3, COL_MENUCONTENT_PLUS_1); - int pb_frame = 0; + int pb_frame = FRAME_WIDTH_NONE; if (g_settings.theme.progressbar_design_channellist == CProgressBar::PB_MONO && !g_settings.theme.progressbar_gradient) { // add small frame to mono progressbars w/o gradient for a better visibility - pb_frame = 1; + pb_frame = FRAME_WIDTH_MIN; } pb.setFrameThickness(pb_frame); pb.doPaintBg(false); @@ -2283,7 +2283,7 @@ void CChannelList::paintPig(int _x, int _y, int w, int h) if (cc_minitv == NULL){ cc_minitv = new CComponentsPIP (0, 0); cc_minitv->setPicture(NEUTRINO_ICON_AUDIOPLAY); - cc_minitv->setFrameThickness(5); + cc_minitv->setFrameThickness(OFFSET_INNER_SMALL); } //set changeable minitv properties cc_minitv->setDimensionsAll(_x, _y, w, h); diff --git a/src/gui/components/cc_frm_scrollbar.cpp b/src/gui/components/cc_frm_scrollbar.cpp index 13006e722..56891add4 100644 --- a/src/gui/components/cc_frm_scrollbar.cpp +++ b/src/gui/components/cc_frm_scrollbar.cpp @@ -155,7 +155,7 @@ void CComponentsScrollBar::initSegments() //init segment container if (sb_segments_obj == NULL){ sb_segments_obj = new CComponentsFrmChain(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj, NULL, CC_DIR_Y, this, false); - sb_segments_obj->setFrameThickness(0); + sb_segments_obj->setFrameThickness(FRAME_WIDTH_NONE); }else sb_segments_obj->setDimensionsAll(CC_CENTERED, CC_APPEND, w_seg, h_seg_obj); diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp index 543d71a8e..5a639c825 100644 --- a/src/gui/components/cc_item_progressbar.cpp +++ b/src/gui/components/cc_item_progressbar.cpp @@ -450,7 +450,7 @@ void CProgressBar::paintProgress(bool do_save_bg) pb_green /= sum; if (*pb_gradient) - setFrameThickness(0); + setFrameThickness(FRAME_WIDTH_NONE); initDimensions(); diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index 323084f09..72f4298ce 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -344,7 +344,7 @@ void CInfoViewer::showRecordIcon (const bool show) { if (rec == NULL){ //TODO: full refactoring of this icon handler rec = new CComponentsShapeSquare(box_x, box_y , box_w, box_h, NULL, CC_SHADOW_ON, COL_RED, COL_INFOBAR_PLUS_0); - rec->setFrameThickness(2); + rec->setFrameThickness(FRAME_WIDTH_NONE); rec->setShadowWidth(OFFSET_SHADOW/2); rec->setCorner(RADIUS_MIN, CORNER_ALL); } diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index cea2656eb..0a0091a3b 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -863,7 +863,7 @@ void CInfoViewerBB::paint_ca_bar() if (ca_bar == NULL) ca_bar = new CComponentsShapeSquare(g_InfoViewer->ChanInfoX + OFFSET_INNER_MID, g_InfoViewer->BoxEndY, ca_width - 2*OFFSET_INNER_MID, bottom_bar_offset - OFFSET_INNER_MID, NULL, CC_SHADOW_ON, COL_INFOBAR_CASYSTEM_PLUS_2, COL_INFOBAR_CASYSTEM_PLUS_0); ca_bar->enableShadow(CC_SHADOW_ON, OFFSET_SHADOW/2, true); - ca_bar->setFrameThickness(2); + ca_bar->setFrameThickness(FRAME_WIDTH_MIN); ca_bar->setCorner(RADIUS_SMALL, CORNER_ALL); ca_bar->paint(CC_SAVE_SCREEN_NO); } diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index e6a97527c..c9e9835cc 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -1629,7 +1629,7 @@ void COsdSetup::paintWindowSize(int w, int h) { if (win_demo == NULL) { win_demo = new CComponentsShapeSquare(0, 0, 0, 0); - win_demo->setFrameThickness(8); + win_demo->setFrameThickness(OFFSET_INNER_MID); win_demo->disableShadow(); win_demo->setColorBody(COL_BACKGROUND); win_demo->setColorFrame(COL_RED); diff --git a/src/gui/volumebar.cpp b/src/gui/volumebar.cpp index 6205ee322..27c66fa6e 100644 --- a/src/gui/volumebar.cpp +++ b/src/gui/volumebar.cpp @@ -198,7 +198,7 @@ void CVolumeBar::initVolumeBarScale() vb_pb->setType(CProgressBar::PB_REDRIGHT); vb_pb->setRgb(85, 75, 100); - vb_pb->setFrameThickness(2); + vb_pb->setFrameThickness(FRAME_WIDTH_NONE); vb_pb->setProgress(vb_pbx, vb_pby, vb_pbw, vb_pbh, *vb_vol, 100); } diff --git a/src/gui/widget/colorchooser.cpp b/src/gui/widget/colorchooser.cpp index f4dfed170..9cee6d6f9 100644 --- a/src/gui/widget/colorchooser.cpp +++ b/src/gui/widget/colorchooser.cpp @@ -117,7 +117,7 @@ void CColorChooser::setColor() else { CComponentsShapeSquare preview(preview_x, preview_y, preview_w, preview_h, NULL, false, COL_FRAME_PLUS_0, col); - preview.setFrameThickness(1); + preview.setFrameThickness(FRAME_WIDTH_MIN); preview.setCorner(RADIUS_SMALL); preview.paint(false); } diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 3b5f75749..8cae40d7d 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -251,7 +251,7 @@ void CMenuItem::paintItemCaption(const bool select_mode, const char * right_text right_frame_col = COL_MENUCONTENTINACTIVE_TEXT; } CComponentsShapeSquare col(stringstartposOption, y + OFFSET_INNER_SMALL, dx - stringstartposOption + x - OFFSET_INNER_MID, item_height - 2*OFFSET_INNER_SMALL, NULL, false, right_frame_col, right_bg_col); - col.setFrameThickness(3); + col.setFrameThickness(FRAME_WIDTH_MIN); col.setCorner(RADIUS_SMALL); col.paint(false); } @@ -1517,7 +1517,7 @@ void CMenuWidget::paintHint(int pos) info_box = new CComponentsInfoBox(); info_box->setDimensionsAll(x, ypos2, iwidth, hint_height); - info_box->setFrameThickness(2); + info_box->setFrameThickness(FRAME_WIDTH_MIN); info_box->removeLineBreaks(str); info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT], COL_MENUCONTENT_TEXT); info_box->setCorner(rad); diff --git a/src/gui/widget/msgbox.cpp b/src/gui/widget/msgbox.cpp index c1cdbfe30..79fa64e93 100644 --- a/src/gui/widget/msgbox.cpp +++ b/src/gui/widget/msgbox.cpp @@ -416,7 +416,7 @@ int ShowMsg2UTF( const char * const Title, Text_mode); if (color_frame != HINTBOX_DEFAULT_FRAME_COLOR){ - msgBox.setFrameThickness(4); + msgBox.setFrameThickness(OFFSET_INNER_SMALL); msgBox.setColorFrame(color_frame); } diff --git a/src/gui/widget/progresswindow.cpp b/src/gui/widget/progresswindow.cpp index 26975c02a..27b4418c8 100644 --- a/src/gui/widget/progresswindow.cpp +++ b/src/gui/widget/progresswindow.cpp @@ -120,7 +120,7 @@ CProgressBar* CProgressWindow::getProgressItem() pBar->setDimensionsAll(OFFSET_INNER_MID, y_tmp, width-2*OFFSET_INNER_MID, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight()); pBar->setColorBody(col_body); pBar->setActiveColor(COL_PROGRESSBAR_ACTIVE_PLUS_0); - pBar->setFrameThickness(1); + pBar->setFrameThickness(FRAME_WIDTH_MIN); pBar->setColorFrame(COL_PROGRESSBAR_ACTIVE_PLUS_0); pBar->setType(CProgressBar::PB_TIMESCALE); addWindowItem(pBar); diff --git a/src/system/settings.h b/src/system/settings.h index ad82d06d0..b6095f21c 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -944,6 +944,7 @@ const time_settings_struct_t timing_setting[SNeutrinoSettings::TIMING_SETTING_CO #define SCROLLBAR_WIDTH (OFFSET_INNER_MID + 2*OFFSET_INNER_MIN) #define FRAME_WIDTH_MIN CFrameBuffer::getInstance()->scale2Res(2) +#define FRAME_WIDTH_NONE 0 #define DETAILSLINE_WIDTH CFrameBuffer::getInstance()->scale2Res(16) From 6e8b743e1eb178e6de554490ed093a5c6d9fc5b0 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Thu, 21 Sep 2017 09:05:06 +0200 Subject: [PATCH 6/6] jsoncpp: update to current version 1.8.3 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9f6e78974bf705a7069f9552a9867f40f7d3d623 Author: Michael Liebmann Date: 2017-09-21 (Thu, 21 Sep 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/jsoncpp/json/json-forwards.h | 21 ++-- lib/jsoncpp/json/json.h | 104 +++++++++++++----- lib/jsoncpp/jsoncpp.cpp | 174 ++++++++++++++++++++++--------- 3 files changed, 217 insertions(+), 82 deletions(-) diff --git a/lib/jsoncpp/json/json-forwards.h b/lib/jsoncpp/json/json-forwards.h index 342438995..b9d46e688 100644 --- a/lib/jsoncpp/json/json-forwards.h +++ b/lib/jsoncpp/json/json-forwards.h @@ -11,13 +11,13 @@ The JsonCpp library's source code, including accompanying documentation, tests and demonstration applications, are licensed under the following conditions... -The author (Baptiste Lepilleur) explicitly disclaims copyright in all +Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all jurisdictions which recognize such a disclaimer. In such jurisdictions, this software is released into the Public Domain. In jurisdictions which do not recognize Public Domain property (e.g. Germany as of -2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is -released under the terms of the MIT License (see below). +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and +The JsonCpp Authors, and is released under the terms of the MIT License (see below). In jurisdictions which recognize Public Domain property, the user of this software may choose to accept it either as 1) Public Domain, 2) under the @@ -32,7 +32,7 @@ described in clear, concise terms at: The full text of the MIT License follows: ======================================================================== -Copyright (c) 2007-2010 Baptiste Lepilleur +Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -83,7 +83,7 @@ license you like. // Beginning of content of file: include/json/config.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -94,6 +94,12 @@ license you like. #include //typedef String #include //typedef int64_t, uint64_t +/* own assert() which does not abort... */ +#define assert(x) do { \ + if (x) \ + fprintf(stderr, "JSONCPP:%s:%d assert(%s) failed\n", __func__, __LINE__, #x); \ +} while (0) + /// If defined, indicates that json library is embedded in CppTL library. //# define JSON_IN_CPPTL 1 @@ -205,6 +211,9 @@ license you like. #endif #ifdef __clang__ +# if __has_extension(attribute_deprecated_with_message) +# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) +# endif #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) @@ -281,7 +290,7 @@ typedef UInt64 LargestUInt; // Beginning of content of file: include/json/forwards.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE diff --git a/lib/jsoncpp/json/json.h b/lib/jsoncpp/json/json.h index 02a31f4a0..0ad699dbc 100644 --- a/lib/jsoncpp/json/json.h +++ b/lib/jsoncpp/json/json.h @@ -10,13 +10,13 @@ The JsonCpp library's source code, including accompanying documentation, tests and demonstration applications, are licensed under the following conditions... -The author (Baptiste Lepilleur) explicitly disclaims copyright in all +Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all jurisdictions which recognize such a disclaimer. In such jurisdictions, this software is released into the Public Domain. In jurisdictions which do not recognize Public Domain property (e.g. Germany as of -2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is -released under the terms of the MIT License (see below). +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and +The JsonCpp Authors, and is released under the terms of the MIT License (see below). In jurisdictions which recognize Public Domain property, the user of this software may choose to accept it either as 1) Public Domain, 2) under the @@ -31,7 +31,7 @@ described in clear, concise terms at: The full text of the MIT License follows: ======================================================================== -Copyright (c) 2007-2010 Baptiste Lepilleur +Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -87,10 +87,10 @@ license you like. #ifndef JSON_VERSION_H_INCLUDED # define JSON_VERSION_H_INCLUDED -# define JSONCPP_VERSION_STRING "1.8.0" +# define JSONCPP_VERSION_STRING "1.8.3" # define JSONCPP_VERSION_MAJOR 1 # define JSONCPP_VERSION_MINOR 8 -# define JSONCPP_VERSION_PATCH 0 +# define JSONCPP_VERSION_PATCH 3 # define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) @@ -116,7 +116,7 @@ license you like. // Beginning of content of file: include/json/config.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -127,6 +127,12 @@ license you like. #include //typedef String #include //typedef int64_t, uint64_t +/* own assert() which does not abort... */ +#define assert(x) do { \ + if (x) \ + fprintf(stderr, "JSONCPP:%s:%d assert(%s) failed\n", __func__, __LINE__, #x); \ +} while (0) + /// If defined, indicates that json library is embedded in CppTL library. //# define JSON_IN_CPPTL 1 @@ -238,6 +244,9 @@ license you like. #endif #ifdef __clang__ +# if __has_extension(attribute_deprecated_with_message) +# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) +# endif #elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc) # if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) # define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message))) @@ -314,7 +323,7 @@ typedef UInt64 LargestUInt; // Beginning of content of file: include/json/forwards.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -365,7 +374,7 @@ class ValueConstIterator; // Beginning of content of file: include/json/features.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -440,7 +449,7 @@ public: // Beginning of content of file: include/json/value.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -465,7 +474,7 @@ public: #endif //Conditional NORETURN attribute on the throw functions would: -// a) suppress false positives from static code analysis +// a) suppress false positives from static code analysis // b) possibly improve optimization opportunities. #if !defined(JSONCPP_NORETURN) # if defined(_MSC_VER) @@ -506,7 +515,7 @@ protected: /** Exceptions which the user cannot easily avoid. * * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input - * + * * \remark derived from Json::Exception */ class JSON_API RuntimeError : public Exception { @@ -517,7 +526,7 @@ public: /** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros. * * These are precondition-violations (user bugs) and internal errors (our bugs). - * + * * \remark derived from Json::Exception */ class JSON_API LogicError : public Exception { @@ -632,6 +641,9 @@ public: typedef Json::LargestUInt LargestUInt; typedef Json::ArrayIndex ArrayIndex; + // Required for boost integration, e. g. BOOST_TEST + typedef std::string value_type; + static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value(). static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null static Value const& nullSingleton(); ///< Prefer this to null or nullRef. @@ -675,7 +687,12 @@ private: CZString(CZString&& other); #endif ~CZString(); - CZString& operator=(CZString other); + CZString& operator=(const CZString& other); + +#if JSON_HAS_RVALUE_REFERENCES + CZString& operator=(CZString&& other); +#endif + bool operator<(CZString const& other) const; bool operator==(CZString const& other) const; ArrayIndex index() const; @@ -765,11 +782,17 @@ Json::Value obj_value(Json::objectValue); // {} /// Deep copy, then swap(other). /// \note Over-write existing comments. To preserve comments, use #swapPayload(). Value& operator=(Value other); + /// Swap everything. void swap(Value& other); /// Swap values but leave comments and source offsets in place. void swapPayload(Value& other); + /// copy everything. + void copy(const Value& other); + /// copy values but leave comments and source offsets in place. + void copyPayload(const Value& other); + ValueType type() const; /// Compare payload only, not comments etc. @@ -880,6 +903,10 @@ Json::Value obj_value(Json::objectValue); // {} /// Equivalent to jsonvalue[jsonvalue.size()] = value; Value& append(const Value& value); +#if JSON_HAS_RVALUE_REFERENCES + Value& append(Value&& value); +#endif + /// Access an object value by name, create a null member if it does not exist. /// \note Because of our implementation, keys are limited to 2^30 -1 chars. /// Exceeding that will cause an exception. @@ -945,10 +972,12 @@ Json::Value obj_value(Json::objectValue); // {} /// \pre type() is objectValue or nullValue /// \post type() is unchanged /// \deprecated + JSONCPP_DEPRECATED("") Value removeMember(const char* key); /// Same as removeMember(const char*) /// \param key may contain embedded nulls. /// \deprecated + JSONCPP_DEPRECATED("") Value removeMember(const JSONCPP_STRING& key); /// Same as removeMember(const char* begin, const char* end, Value* removed), /// but 'key' is null-terminated. @@ -1324,7 +1353,7 @@ inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); } // Beginning of content of file: include/json/reader.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -1358,7 +1387,7 @@ namespace Json { * * \deprecated Use CharReader and CharReaderBuilder. */ -class JSON_API Reader { +class JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") JSON_API Reader { public: typedef char Char; typedef const Char* Location; @@ -1556,6 +1585,9 @@ private: void addComment(Location begin, Location end, CommentPlacement placement); void skipCommentTokens(Token& token); + static bool containsNewLine(Location begin, Location end); + static JSONCPP_STRING normalizeEOL(Location begin, Location end); + typedef std::stack Nodes; Nodes nodes_; Errors errors_; @@ -1746,7 +1778,7 @@ JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&); // Beginning of content of file: include/json/writer.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -1763,7 +1795,7 @@ JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&); // Disable warning C4251: : needs to have dll-interface to // be used by... -#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) +#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 4251) #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) @@ -1888,7 +1920,7 @@ public: /** \brief Abstract class for writers. * \deprecated Use StreamWriter. (And really, this is an implementation detail.) */ -class JSON_API Writer { +class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer { public: virtual ~Writer(); @@ -1904,8 +1936,11 @@ public: * \sa Reader, Value * \deprecated Use StreamWriterBuilder. */ -class JSON_API FastWriter : public Writer { - +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4996) // Deriving from deprecated class +#endif +class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter : public Writer { public: FastWriter(); ~FastWriter() JSONCPP_OVERRIDE {} @@ -1932,6 +1967,9 @@ private: bool dropNullPlaceholders_; bool omitEndingLineFeed_; }; +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /** \brief Writes a Value in JSON format in a *human friendly way. @@ -1957,7 +1995,11 @@ private: * \sa Reader, Value, Value::setComment() * \deprecated Use StreamWriterBuilder. */ -class JSON_API StyledWriter : public Writer { +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4996) // Deriving from deprecated class +#endif +class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter : public Writer { public: StyledWriter(); ~StyledWriter() JSONCPP_OVERRIDE {} @@ -1992,6 +2034,9 @@ private: unsigned int indentSize_; bool addChildValues_; }; +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /** \brief Writes a Value in JSON format in a human friendly way, @@ -2015,12 +2060,18 @@ private: * If the Value have comments then they are outputed according to their #CommentPlacement. * - * \param indentation Each level will be indented by this amount extra. * \sa Reader, Value, Value::setComment() * \deprecated Use StreamWriterBuilder. */ -class JSON_API StyledStreamWriter { +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4996) // Deriving from deprecated class +#endif +class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter { public: +/** + * \param indentation Each level will be indented by this amount extra. + */ StyledStreamWriter(JSONCPP_STRING indentation = "\t"); ~StyledStreamWriter() {} @@ -2057,6 +2108,9 @@ private: bool addChildValues_ : 1; bool indented_ : 1; }; +#if defined(_MSC_VER) +#pragma warning(pop) +#endif #if defined(JSON_HAS_INT64) JSONCPP_STRING JSON_API valueToString(Int value); @@ -2095,7 +2149,7 @@ JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root); // Beginning of content of file: include/json/assertions.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE diff --git a/lib/jsoncpp/jsoncpp.cpp b/lib/jsoncpp/jsoncpp.cpp index 7634ed4f3..ce72ec1d8 100644 --- a/lib/jsoncpp/jsoncpp.cpp +++ b/lib/jsoncpp/jsoncpp.cpp @@ -10,13 +10,13 @@ The JsonCpp library's source code, including accompanying documentation, tests and demonstration applications, are licensed under the following conditions... -The author (Baptiste Lepilleur) explicitly disclaims copyright in all +Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all jurisdictions which recognize such a disclaimer. In such jurisdictions, this software is released into the Public Domain. In jurisdictions which do not recognize Public Domain property (e.g. Germany as of -2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is -released under the terms of the MIT License (see below). +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and +The JsonCpp Authors, and is released under the terms of the MIT License (see below). In jurisdictions which recognize Public Domain property, the user of this software may choose to accept it either as 1) Public Domain, 2) under the @@ -31,7 +31,7 @@ described in clear, concise terms at: The full text of the MIT License follows: ======================================================================== -Copyright (c) 2007-2010 Baptiste Lepilleur +Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -84,7 +84,7 @@ license you like. // Beginning of content of file: src/lib_json/json_tool.h // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -215,7 +215,7 @@ static inline void fixNumericLocaleInput(char* begin, char* end) { // Beginning of content of file: src/lib_json/json_reader.cpp // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2011 Baptiste Lepilleur +// Copyright 2007-2011 Baptiste Lepilleur and The JsonCpp Authors // Copyright (C) 2016 InfoTeCS JSC. All rights reserved. // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. @@ -229,7 +229,7 @@ static inline void fixNumericLocaleInput(char* begin, char* end) { #endif // if !defined(JSON_IS_AMALGAMATION) #include #include -#include +//#include #include #include #include @@ -298,7 +298,7 @@ Features Features::strictMode() { // Implementation of class Reader // //////////////////////////////// -static bool containsNewLine(Reader::Location begin, Reader::Location end) { +bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) { for (; begin < end; ++begin) if (*begin == '\n' || *begin == '\r') return true; @@ -320,8 +320,7 @@ Reader::Reader(const Features& features) bool Reader::parse(const std::string& document, Value& root, bool collectComments) { - JSONCPP_STRING documentCopy(document.data(), document.data() + document.capacity()); - std::swap(documentCopy, document_); + document_.assign(document.begin(), document.end()); const char* begin = document_.c_str(); const char* end = begin + document_.length(); return parse(begin, end, root, collectComments); @@ -354,7 +353,7 @@ bool Reader::parse(const char* beginDoc, current_ = begin_; lastValueEnd_ = 0; lastValue_ = 0; - commentsBefore_ = ""; + commentsBefore_.clear(); errors_.clear(); while (!nodes_.empty()) nodes_.pop(); @@ -393,7 +392,7 @@ bool Reader::readValue() { if (collectComments_ && !commentsBefore_.empty()) { currentValue().setComment(commentsBefore_, commentBefore); - commentsBefore_ = ""; + commentsBefore_.clear(); } switch (token.type_) { @@ -587,7 +586,7 @@ bool Reader::readComment() { return true; } -static JSONCPP_STRING normalizeEOL(Reader::Location begin, Reader::Location end) { +JSONCPP_STRING Reader::normalizeEOL(Reader::Location begin, Reader::Location end) { JSONCPP_STRING normalized; normalized.reserve(static_cast(end - begin)); Reader::Location current = begin; @@ -691,7 +690,7 @@ bool Reader::readObject(Token& tokenStart) { break; if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object return true; - name = ""; + name.clear(); if (tokenName.type_ == tokenString) { if (!decodeString(tokenName, name)) return recoverFromError(tokenObjectEnd); @@ -1236,6 +1235,9 @@ private: void addComment(Location begin, Location end, CommentPlacement placement); void skipCommentTokens(Token& token); + static JSONCPP_STRING normalizeEOL(Location begin, Location end); + static bool containsNewLine(Location begin, Location end); + typedef std::stack Nodes; Nodes nodes_; Errors errors_; @@ -1253,6 +1255,13 @@ private: // complete copy of Read impl, for OurReader +bool OurReader::containsNewLine(OurReader::Location begin, OurReader::Location end) { + for (; begin < end; ++begin) + if (*begin == '\n' || *begin == '\r') + return true; + return false; +} + OurReader::OurReader(OurFeatures const& features) : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(), lastValue_(), commentsBefore_(), @@ -1273,7 +1282,7 @@ bool OurReader::parse(const char* beginDoc, current_ = begin_; lastValueEnd_ = 0; lastValue_ = 0; - commentsBefore_ = ""; + commentsBefore_.clear(); errors_.clear(); while (!nodes_.empty()) nodes_.pop(); @@ -1315,7 +1324,7 @@ bool OurReader::readValue() { if (collectComments_ && !commentsBefore_.empty()) { currentValue().setComment(commentsBefore_, commentBefore); - commentsBefore_ = ""; + commentsBefore_.clear(); } switch (token.type_) { @@ -1562,6 +1571,25 @@ bool OurReader::readComment() { return true; } +JSONCPP_STRING OurReader::normalizeEOL(OurReader::Location begin, OurReader::Location end) { + JSONCPP_STRING normalized; + normalized.reserve(static_cast(end - begin)); + OurReader::Location current = begin; + while (current != end) { + char c = *current++; + if (c == '\r') { + if (current != end && *current == '\n') + // convert dos EOL + ++current; + // convert Mac EOL + normalized += '\n'; + } else { + normalized += c; + } + } + return normalized; +} + void OurReader::addComment(Location begin, Location end, CommentPlacement placement) { assert(collectComments_); @@ -1664,7 +1692,7 @@ bool OurReader::readObject(Token& tokenStart) { break; if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object return true; - name = ""; + name.clear(); if (tokenName.type_ == tokenString) { if (!decodeString(tokenName, name)) return recoverFromError(tokenObjectEnd); @@ -2241,10 +2269,6 @@ JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) { JSONCPP_STRING errs; bool ok = parseFromStream(b, sin, &root, &errs); if (!ok) { - fprintf(stderr, - "Error from reader: %s", - errs.c_str()); - throwRuntimeError(errs); } return sin; @@ -2265,7 +2289,7 @@ JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) { // Beginning of content of file: src/lib_json/json_valueiterator.inl // ////////////////////////////////////////////////////////////////////// -// Copyright 2007-2010 Baptiste Lepilleur +// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -2446,7 +2470,7 @@ ValueIterator& ValueIterator::operator=(const SelfType& other) { // Beginning of content of file: src/lib_json/json_value.cpp // ////////////////////////////////////////////////////////////////////// -// Copyright 2011 Baptiste Lepilleur +// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -2460,7 +2484,7 @@ ValueIterator& ValueIterator::operator=(const SelfType& other) { #include #include #include -#include +//#include #ifdef JSON_USE_CPPTL #include #endif @@ -2740,11 +2764,21 @@ void Value::CZString::swap(CZString& other) { std::swap(index_, other.index_); } -Value::CZString& Value::CZString::operator=(CZString other) { - swap(other); +Value::CZString& Value::CZString::operator=(const CZString& other) { + cstr_ = other.cstr_; + index_ = other.index_; return *this; } +#if JSON_HAS_RVALUE_REFERENCES +Value::CZString& Value::CZString::operator=(CZString&& other) { + cstr_ = other.cstr_; + index_ = other.index_; + other.cstr_ = nullptr; + return *this; +} +#endif + bool Value::CZString::operator<(const CZString& other) const { if (!cstr_) return index_ < other.index_; //return strcmp(cstr_, other.cstr_) < 0; @@ -2846,7 +2880,7 @@ Value::Value(double value) { Value::Value(const char* value) { initBasic(stringValue, true); - JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor"); + JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor"); value_.string_ = duplicateAndPrefixStringValue(value, static_cast(strlen(value))); } @@ -2971,6 +3005,12 @@ void Value::swapPayload(Value& other) { other.allocated_ = temp2 & 0x1; } +void Value::copyPayload(const Value& other) { + type_ = other.type_; + value_ = other.value_; + allocated_ = other.allocated_; +} + void Value::swap(Value& other) { swapPayload(other); std::swap(comments_, other.comments_); @@ -2978,6 +3018,13 @@ void Value::swap(Value& other) { std::swap(limit_, other.limit_); } +void Value::copy(const Value& other) { + copyPayload(other); + comments_ = other.comments_; + start_ = other.start_; + limit_ = other.limit_; +} + ValueType Value::type() const { return type_; } int Value::compare(const Value& other) const { @@ -3328,7 +3375,7 @@ bool Value::isConvertibleTo(ValueType other) const { case nullValue: return (isNumeric() && asDouble() == 0.0) || (type_ == booleanValue && value_.bool_ == false) || - (type_ == stringValue && asString() == "") || + (type_ == stringValue && asString().empty()) || (type_ == arrayValue && value_.map_->size() == 0) || (type_ == objectValue && value_.map_->size() == 0) || type_ == nullValue; @@ -3572,6 +3619,10 @@ Value const& Value::operator[](CppTL::ConstString const& key) const Value& Value::append(const Value& value) { return (*this)[size()] = value; } +#if JSON_HAS_RVALUE_REFERENCES + Value& Value::append(Value&& value) { return (*this)[size()] = std::move(value); } +#endif + Value Value::get(char const* key, char const* cend, Value const& defaultValue) const { Value const* found = find(key, cend); @@ -3608,6 +3659,9 @@ bool Value::removeMember(JSONCPP_STRING const& key, Value* removed) { return removeMember(key.data(), key.data() + key.length(), removed); } + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" Value Value::removeMember(const char* key) { JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue, @@ -3623,6 +3677,7 @@ Value Value::removeMember(const JSONCPP_STRING& key) { return removeMember(key.c_str()); } +#pragma GCC diagnostic pop bool Value::removeIndex(ArrayIndex index, Value* removed) { if (type_ != arrayValue) { @@ -3808,11 +3863,23 @@ bool Value::isUInt64() const { } bool Value::isIntegral() const { + switch (type_) { + case intValue: + case uintValue: + return true; + case realValue: #if defined(JSON_HAS_INT64) - return isInt64() || isUInt64(); + // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a + // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we + // require the value to be strictly less than the limit. + return value_.real_ >= double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_); #else - return isInt() || isUInt(); -#endif + return value_.real_ >= minInt && value_.real_ <= maxUInt && IsIntegral(value_.real_); +#endif // JSON_HAS_INT64 + default: + break; + } + return false; } bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; } @@ -3862,8 +3929,13 @@ ptrdiff_t Value::getOffsetStart() const { return start_; } ptrdiff_t Value::getOffsetLimit() const { return limit_; } JSONCPP_STRING Value::toStyledString() const { - StyledWriter writer; - return writer.write(*this); + StreamWriterBuilder builder; + + JSONCPP_STRING out = this->hasComment(commentBefore) ? "\n" : ""; + out += Json::writeString(builder, *this); + out += "\n"; + + return out; } Value::const_iterator Value::begin() const { @@ -3942,6 +4014,7 @@ Path::Path(const JSONCPP_STRING& path, const PathArgument& a4, const PathArgument& a5) { InArgs in; + in.reserve(5); in.push_back(&a1); in.push_back(&a2); in.push_back(&a3); @@ -4077,7 +4150,7 @@ Value& Path::make(Value& root) const { // Beginning of content of file: src/lib_json/json_writer.cpp // ////////////////////////////////////////////////////////////////////// -// Copyright 2011 Baptiste Lepilleur +// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors // Distributed under MIT license, or public domain if desired and // recognized in your jurisdiction. // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE @@ -4091,7 +4164,7 @@ Value& Path::make(Value& root) const { #include #include #include -#include +//#include #include #include @@ -4221,17 +4294,18 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p char buffer[36]; int len = -1; - char formatString[6]; - sprintf(formatString, "%%.%dg", precision); + char formatString[15]; + snprintf(formatString, sizeof(formatString), "%%.%dg", precision); // Print into the buffer. We need not request the alternative representation // that always has a decimal point because JSON doesn't distingish the // concepts of reals and integers. if (isfinite(value)) { len = snprintf(buffer, sizeof(buffer), formatString, value); - + fixNumericLocale(buffer, buffer + len); + // try to ensure we preserve the fact that this was given to us as a double on input - if (!strstr(buffer, ".") && !strstr(buffer, "e")) { + if (!strchr(buffer, '.') && !strchr(buffer, 'e')) { strcat(buffer, ".0"); } @@ -4244,10 +4318,8 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p } else { len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999"); } - // For those, we do not need to call fixNumLoc, but it is fast. } assert(len >= 0); - fixNumericLocale(buffer, buffer + len); return buffer; } } @@ -4414,7 +4486,7 @@ void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; } void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; } JSONCPP_STRING FastWriter::write(const Value& root) { - document_ = ""; + document_.clear(); writeValue(root); if (!omitEndingLineFeed_) document_ += "\n"; @@ -4482,9 +4554,9 @@ StyledWriter::StyledWriter() : rightMargin_(74), indentSize_(3), addChildValues_() {} JSONCPP_STRING StyledWriter::write(const Value& root) { - document_ = ""; + document_.clear(); addChildValues_ = false; - indentString_ = ""; + indentString_.clear(); writeCommentBeforeValue(root); writeValue(root); writeCommentAfterValueOnSameLine(root); @@ -4662,7 +4734,7 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) { while (iter != comment.end()) { document_ += *iter; if (*iter == '\n' && - (iter != comment.end() && *(iter + 1) == '/')) + ((iter+1) != comment.end() && *(iter + 1) == '/')) writeIndent(); ++iter; } @@ -4698,7 +4770,7 @@ StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation) void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) { document_ = &out; addChildValues_ = false; - indentString_ = ""; + indentString_.clear(); indented_ = true; writeCommentBeforeValue(root); if (!indented_) writeIndent(); @@ -4878,7 +4950,7 @@ void StyledStreamWriter::writeCommentBeforeValue(const Value& root) { while (iter != comment.end()) { *document_ << *iter; if (*iter == '\n' && - (iter != comment.end() && *(iter + 1) == '/')) + ((iter+1) != comment.end() && *(iter + 1) == '/')) // writeIndent(); // would include newline *document_ << indentString_; ++iter; @@ -4980,7 +5052,7 @@ int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout) sout_ = sout; addChildValues_ = false; indented_ = true; - indentString_ = ""; + indentString_.clear(); writeCommentBeforeValue(root); if (!indented_) writeIndent(); indented_ = true; @@ -5166,7 +5238,7 @@ void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) { while (iter != comment.end()) { *sout_ << *iter; if (*iter == '\n' && - (iter != comment.end() && *(iter + 1) == '/')) + ((iter+1) != comment.end() && *(iter + 1) == '/')) // writeIndent(); // would write extra newline *sout_ << indentString_; ++iter; @@ -5234,10 +5306,10 @@ StreamWriter* StreamWriterBuilder::newStreamWriter() const } JSONCPP_STRING nullSymbol = "null"; if (dnp) { - nullSymbol = ""; + nullSymbol.clear(); } if (pre > 17) pre = 17; - JSONCPP_STRING endingLineFeedSymbol = ""; + JSONCPP_STRING endingLineFeedSymbol; return new BuiltStyledStreamWriter( indentation, cs, colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);