Skip to content

Commit 4ea5e75

Browse files
committed
Changed shared_ptr behaviour to new behaviour. Added shared_ptr to parser.
1 parent e208d25 commit 4ea5e75

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

parse/jsd_shared_ptr.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include "jsd_smart_ptr.h"
4+
5+
#include "../utility/polymorphy.h"
6+
7+
#include <memory>
8+
9+
namespace JSON
10+
{
11+
template <typename T>
12+
void parse(std::shared_ptr <T>& value, std::string const& name,
13+
PropertyTree const& object, ParsingOptions const& options = {})
14+
{
15+
internal::parse_smart_ptr(value, name, object, options);
16+
}
17+
}

stringify/jss_shared_ptr.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
#ifndef JSS_SHARED_PTR_H_INCLUDED
22
#define JSS_SHARED_PTR_H_INCLUDED
33

4-
#include "jss_core.h"
4+
#include "jss_core.h"
5+
#include "jss_smart_ptr.h"
6+
#include "../utility/polymorphy.h"
7+
58
#include <memory>
69

710
namespace JSON
811
{
912
template <typename T,
10-
typename = typename std::enable_if <Internal::can_stringify<T>::value>::type >
13+
typename = typename std::enable_if <
14+
Internal::can_stringify<T>::value ||
15+
!std::is_same <typename polydecls <T>::type, no_poly>::value
16+
>::type >
1117
std::ostream& stringify (std::ostream& stream, const std::string& name, std::shared_ptr<T> const& value, StringificationOptions const& options = DEFAULT_OPTIONS)
1218
{
1319
if (!value)
1420
throw SharedPtrNullptrException{};
15-
return stringify(stream, name, *value, options);
21+
22+
return internal::stringify_smart_ptr(stream, name, value, options);
1623
}
1724
}
1825

stringify/jss_weak_ptr.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
#ifndef JSS_WEAK_PTR_H_INCLUDED
22
#define JSS_WEAK_PTR_H_INCLUDED
33

4-
#include "jss_core.h"
4+
#include "jss_core.h"
5+
#include "jss_smart_ptr.h"
6+
#include "../utility/polymorphy.h"
7+
58
#include <memory>
69

710

811
namespace JSON
912
{
1013
template <typename T,
11-
typename = typename std::enable_if <Internal::can_stringify<T>::value>::type >
14+
typename = typename std::enable_if <
15+
Internal::can_stringify<T>::value ||
16+
!std::is_same <typename polydecls <T>::type, no_poly>::value
17+
>::type >
1218
std::ostream& stringify (std::ostream& stream, const std::string& name, std::weak_ptr<T> const& value, StringificationOptions const& options = DEFAULT_OPTIONS)
1319
{
1420
if (value.expired())
15-
throw WeakPtrExpiredException{};
16-
return stringify(stream, name, value.lock(), options);
21+
throw WeakPtrExpiredException{};
22+
23+
return internal::stringify_smart_ptr(stream, name, value, options);
1724
}
1825

1926
}

0 commit comments

Comments
 (0)