VirtualBox

source: vbox/trunk/include/iprt/cpp/restanyobject.h@ 82968

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/** @file
2 * IPRT - C++ Representational State Transfer (REST) Any Object Class.
3 */
4
5/*
6 * Copyright (C) 2008-2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_cpp_restanyobject_h
27#define IPRT_INCLUDED_cpp_restanyobject_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cpp/restbase.h>
33#include <iprt/cpp/restarray.h>
34#include <iprt/cpp/reststringmap.h>
35
36
37/** @defgroup grp_rt_cpp_restanyobj C++ Representational State Transfer (REST) Any Object Class.
38 * @ingroup grp_rt_cpp
39 * @{
40 */
41
42/**
43 * Wrapper object that can represent any kind of basic REST object.
44 *
45 * This class is the result of a couple of design choices made in our REST
46 * data model. If could have been avoided if we used pointers all over
47 * the place and didn't rely entirely on the object specific implementations
48 * of deserializeFromJson and fromString to do the deserializing or everything.
49 *
50 * The assumption, though, was that most of the data we're dealing with has a
51 * known structure and maps to fixed types. So, the data model was optimized
52 * for that rather than flexiblity here.
53 */
54class RT_DECL_CLASS RTCRestAnyObject : public RTCRestObjectBase
55{
56public:
57 /** Default constructor. */
58 RTCRestAnyObject() RT_NOEXCEPT;
59 /** Destructor. */
60 virtual ~RTCRestAnyObject();
61
62 /** Copy constructor. */
63 RTCRestAnyObject(RTCRestAnyObject const &a_rThat);
64 /** Copy assignment operator. */
65 RTCRestAnyObject &operator=(RTCRestAnyObject const &a_rThat);
66
67 /** Safe copy assignment method. */
68 int assignCopy(RTCRestAnyObject const &a_rThat) RT_NOEXCEPT;
69 /** Safe copy assignment method, boolean variant. */
70 int assignCopy(RTCRestBool const &a_rThat) RT_NOEXCEPT;
71 /** Safe copy assignment method, int64_t variant. */
72 int assignCopy(RTCRestInt64 const &a_rThat) RT_NOEXCEPT;
73 /** Safe copy assignment method, int32_t variant. */
74 int assignCopy(RTCRestInt32 const &a_rThat) RT_NOEXCEPT;
75 /** Safe copy assignment method, int16_t variant. */
76 int assignCopy(RTCRestInt16 const &a_rThat) RT_NOEXCEPT;
77 /** Safe copy assignment method, double variant. */
78 int assignCopy(RTCRestDouble const &a_rThat) RT_NOEXCEPT;
79 /** Safe copy assignment method, string variant. */
80 int assignCopy(RTCRestString const &a_rThat) RT_NOEXCEPT;
81 /** Safe copy assignment method, array variant. */
82 int assignCopy(RTCRestArray<RTCRestAnyObject> const &a_rThat) RT_NOEXCEPT;
83 /** Safe copy assignment method, string map variant. */
84 int assignCopy(RTCRestStringMap<RTCRestAnyObject> const &a_rThat) RT_NOEXCEPT;
85
86 /** Safe value assignment method, boolean variant. */
87 int assignValue(bool a_fValue) RT_NOEXCEPT;
88 /** Safe value assignment method, int64_t variant. */
89 int assignValue(int64_t a_iValue) RT_NOEXCEPT;
90 /** Safe value assignment method, int32_t variant. */
91 int assignValue(int32_t a_iValue) RT_NOEXCEPT;
92 /** Safe value assignment method, int16_t variant. */
93 int assignValue(int16_t a_iValue) RT_NOEXCEPT;
94 /** Safe value assignment method, double variant. */
95 int assignValue(double a_iValue) RT_NOEXCEPT;
96 /** Safe value assignment method, string variant. */
97 int assignValue(RTCString const &a_rValue) RT_NOEXCEPT;
98 /** Safe value assignment method, C-string variant. */
99 int assignValue(const char *a_pszValue) RT_NOEXCEPT;
100
101 /** Make a clone of this object. */
102 inline RTCRestAnyObject *clone() const RT_NOEXCEPT { return (RTCRestAnyObject *)baseClone(); }
103
104 /* Overridden methods: */
105 virtual RTCRestObjectBase *baseClone() const RT_NOEXCEPT RT_OVERRIDE;
106 virtual int setNull(void) RT_NOEXCEPT RT_OVERRIDE;
107 virtual int resetToDefault() RT_NOEXCEPT RT_OVERRIDE;
108 virtual RTCRestOutputBase &serializeAsJson(RTCRestOutputBase &a_rDst) const RT_NOEXCEPT RT_OVERRIDE;
109 virtual int deserializeFromJson(RTCRestJsonCursor const &a_rCursor) RT_NOEXCEPT RT_OVERRIDE;
110 virtual int toString(RTCString *a_pDst, uint32_t a_fFlags = kCollectionFormat_Unspecified) const RT_NOEXCEPT RT_OVERRIDE;
111 virtual int fromString(RTCString const &a_rValue, const char *a_pszName, PRTERRINFO a_pErrInfo = NULL,
112 uint32_t a_fFlags = kCollectionFormat_Unspecified) RT_NOEXCEPT RT_OVERRIDE;
113 virtual kTypeClass typeClass(void) const RT_NOEXCEPT RT_OVERRIDE;
114 virtual const char *typeName(void) const RT_NOEXCEPT RT_OVERRIDE;
115
116 /** Factory method. */
117 static DECLCALLBACK(RTCRestObjectBase *) createInstance(void) RT_NOEXCEPT;
118 /** Deserialization w/ instantiation. */
119 static FNDESERIALIZEINSTANCEFROMJSON deserializeInstanceFromJson;
120
121protected:
122 /** The data. */
123 RTCRestObjectBase *m_pData;
124};
125
126/** @} */
127
128#endif /* !IPRT_INCLUDED_cpp_restanyobject_h */
129
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette