Skip to content

Commit 141e6ba

Browse files
committed
Use std::stoll to convert JSON values
1 parent e95d184 commit 141e6ba

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

include/CacheBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define OPENSHOT_CACHE_BASE_H
3333

3434
#include <memory>
35+
#include <cstdlib>
3536
#include "Frame.h"
3637
#include "Exceptions.h"
3738
#include "Json.h"

include/ChunkReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <omp.h>
4040
#include <QtCore/qdir.h>
4141
#include <stdio.h>
42-
#include <stdlib.h>
42+
#include <cstdlib>
4343
#include <memory>
4444
#include "Json.h"
4545
#include "CacheMemory.h"

include/ReaderBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <iostream>
3535
#include <iomanip>
3636
#include <memory>
37-
#include <stdlib.h>
37+
#include <cstdlib>
3838
#include <sstream>
3939
#include "CacheMemory.h"
4040
#include "ChannelLayouts.h"

src/CacheBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@ void CacheBase::SetJsonValue(Json::Value root) {
7171

7272
// Set data from Json (if key is found)
7373
if (!root["max_bytes"].isNull())
74-
max_bytes = atoll(root["max_bytes"].asString().c_str());
74+
max_bytes = std::stoll(root["max_bytes"].asString());
7575
}

src/ChunkReader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void ChunkReader::load_json()
9494
info.has_video = root["has_video"].asBool();
9595
info.has_audio = root["has_audio"].asBool();
9696
info.duration = root["duration"].asDouble();
97-
info.file_size = atoll(root["file_size"].asString().c_str());
97+
info.file_size = std::stoll(root["file_size"].asString());
9898
info.height = root["height"].asInt();
9999
info.width = root["width"].asInt();
100100
info.pixel_format = root["pixel_format"].asInt();
@@ -106,7 +106,7 @@ void ChunkReader::load_json()
106106
info.display_ratio.num = root["display_ratio"]["num"].asInt();
107107
info.display_ratio.den = root["display_ratio"]["den"].asInt();
108108
info.vcodec = root["vcodec"].asString();
109-
info.video_length = atoll(root["video_length"].asString().c_str());
109+
info.video_length = std::stoll(root["video_length"].asString());
110110
info.video_stream_index = root["video_stream_index"].asInt();
111111
info.video_timebase.num = root["video_timebase"]["num"].asInt();
112112
info.video_timebase.den = root["video_timebase"]["den"].asInt();
@@ -316,7 +316,7 @@ void ChunkReader::SetJsonValue(Json::Value root) {
316316
if (!root["path"].isNull())
317317
path = root["path"].asString();
318318
if (!root["chunk_size"].isNull())
319-
chunk_size = atoll(root["chunk_size"].asString().c_str());
319+
chunk_size = std::stoll(root["chunk_size"].asString());
320320
if (!root["chunk_version"].isNull())
321321
version = (ChunkVersion) root["chunk_version"].asInt();
322322

src/ReaderBase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void ReaderBase::SetJsonValue(Json::Value root) {
181181
if (!root["duration"].isNull())
182182
info.duration = root["duration"].asDouble();
183183
if (!root["file_size"].isNull())
184-
info.file_size = atoll(root["file_size"].asString().c_str());
184+
info.file_size = std::stoll(root["file_size"].asString());
185185
if (!root["height"].isNull())
186186
info.height = root["height"].asInt();
187187
if (!root["width"].isNull())
@@ -211,7 +211,7 @@ void ReaderBase::SetJsonValue(Json::Value root) {
211211
if (!root["vcodec"].isNull())
212212
info.vcodec = root["vcodec"].asString();
213213
if (!root["video_length"].isNull())
214-
info.video_length = atoll(root["video_length"].asString().c_str());
214+
info.video_length = std::stoll(root["video_length"].asString());
215215
if (!root["video_stream_index"].isNull())
216216
info.video_stream_index = root["video_stream_index"].asInt();
217217
if (!root["video_timebase"].isNull() && root["video_timebase"].isObject()) {

0 commit comments

Comments
 (0)