aboutsummaryrefslogtreecommitdiffstats
path: root/doc/reference/jsextensions/jsextension-propertylist.qdoc
blob: b6fe87f906e2f3cc2b2f15eca1533accc997551f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qbs.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/

/*!
    \contentspage index.html
    \page jsextension-propertylist.html
    \ingroup list-of-builtin-services

    \title PropertyList Service
    \brief Provides read, write and convert operations on property list files.

    The \c PropertyList service allows you to read and write property list files in
    all formats supported by the Core Foundation API: XML, binary, JSON, and OpenStep (read-only).

    This service is only available on Darwin platforms such as iOS, macOS, tvOS, and watchOS.

    \section1 Available operations

    \section2 Constructor
    \code
    PropertyList()
    \endcode
    Allocates and returns a new PropertyList object.

    \section2 clear
    \code
    clear(): void
    \endcode
    Voids the property list by deleting its internal object reference.

    \section2 isEmpty
    \code
    isEmpty(): boolean
    \endcode
    Returns true if the property list has no internal object reference set, otherwise false.

    \section2 format
    \code
    format(): string
    \endcode
    Returns the data format that the property list data was deserialized from. This property is set
    after calling \c readFromString or \c readFromFile.
    Possible return values include: \c "binary1", \c "json", \c "openstep", and \c "xml1".
    If the property list object is empty or the input format could not be determined,
    returns \c undefined.

    \section2 readFromFile
    \code
    readFromFile(filePath: string): void
    \endcode
    Parses the file and stores the result in the property list.
    Throws an exception if an I/O error occurs or the input is in an invalid format.

    \section2 readFromObject
    \code
    readFromObject(obj: any): void
    \endcode
    Sets the given object as the property list's internal object.
    \c format() will return \c undefined as this method does not deserialize a storage format.

    \section2 readFromString
    \code
    readFromString(input: string): void
    \endcode
    Parses \c input and stores the result in the property list.
    This is most useful for initializing a property list object from the result of a
    \c JSON.stringify call.
    Throws an exception if the input is in an invalid format.

    \section2 toObject
    \code
    toObject(): any
    \endcode
    Returns an object representing the property list.

    \section2 toJSON
    \code
    toJSON(style: string = "compact"): string
    \endcode
    Returns a string representation of the property list in JSON format.
    Possible values for \c style include \c "pretty" and \c "compact". The default is compact.

    \section2 toString
    \code
    toString(format: string): string
    \endcode
    Returns a string representation of the property list in the specified format.
    Possible values for \c format include: \c "json" (compact), \c "json-compact", \c "json-pretty",
    and \c "xml1". Currently, the OpenStep format is not supported.
    Throws an exception if the object cannot be written in the given format.

    \section2 toXMLString
    \code
    toXMLString(): string
    \endcode
    Returns a string representation of the property list in XML format.
    This function is a synonym for \c toString("xml1").

    \section2 writeToFile
    \code
    writeToFile(filePath: string, format: string): void
    \endcode
    Writes the property list to the file in the given format.
    Possible values for \c format include: \c "binary1", \c "json" (compact), \c "json-compact",
    \c "json-pretty", and \c "xml1". Currently, the OpenStep format is not supported for writing.
    Throws an exception if an I/O error occurs or the object cannot be written in the given format.
*/