1 /* libcmis
2  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License or as specified alternatively below. You may obtain a copy of
7  * the License at http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * Major Contributor(s):
15  * Copyright (C) 2011 SUSE <cbosdonnat@suse.com>
16  *
17  *
18  * All Rights Reserved.
19  *
20  * For minor contributions see the git repository.
21  *
22  * Alternatively, the contents of this file may be used under the terms of
23  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
24  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
25  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
26  * instead of those above.
27  */
28 #ifndef _PROPERTY_TYPE_HXX_
29 #define _PROPERTY_TYPE_HXX_
30 
31 #include <boost/date_time.hpp>
32 #include <libxml/tree.h>
33 
34 #include <string>
35 
36 #include "libcmis/libcmis-api.h"
37 
38 namespace libcmis
39 {
40     class ObjectType;
41     typedef boost::shared_ptr< ObjectType > ObjectTypePtr;
42 
43     class LIBCMIS_API PropertyType
44     {
45         public:
46 
47             enum Type
48             {
49                 String,
50                 Integer,
51                 Decimal,
52                 Bool,
53                 DateTime
54             };
55 
56         private:
57 
58             std::string m_id;
59             std::string m_localName;
60             std::string m_localNamespace;
61             std::string m_displayName;
62             std::string m_queryName;
63             Type m_type;
64             std::string m_xmlType;
65             bool m_multiValued;
66             bool m_updatable;
67             bool m_inherited;
68             bool m_required;
69             bool m_queryable;
70             bool m_orderable;
71             bool m_openChoice;
72             bool m_temporary;
73 
74         public:
75 
76             /// Default constructor, mostly present for testing.
77             PropertyType( );
78             PropertyType( xmlNodePtr node );
79             PropertyType( const PropertyType& copy );
80             /// constructor for temporary type definitions
81             PropertyType( std::string type,
82                           std::string id,
83                           std::string localName,
84                           std::string displayName,
85                           std::string queryName );
~PropertyType()86             virtual ~PropertyType( ) { };
87 
88             PropertyType& operator=( const PropertyType& copy );
89 
getId()90             std::string getId( ) { return m_id; }
getLocalName()91             std::string getLocalName( ) { return m_localName; }
getLocalNamespace()92             std::string getLocalNamespace( ) { return m_localNamespace; }
getDisplayName()93             std::string getDisplayName( ) { return m_displayName; }
getQueryName()94             std::string getQueryName( ) { return m_queryName; }
getType()95             Type getType( ) { return m_type; }
getXmlType()96             std::string getXmlType( ) { return m_xmlType; }
isMultiValued()97             bool isMultiValued( ) { return m_multiValued; }
isUpdatable()98             bool isUpdatable( ) { return m_updatable; }
isInherited()99             bool isInherited( ) { return m_inherited; }
isRequired()100             bool isRequired( ) { return m_required; }
isQueryable()101             bool isQueryable( ) { return m_queryable; }
isOrderable()102             bool isOrderable( ) { return m_orderable; }
isOpenChoice()103             bool isOpenChoice( ) { return m_openChoice; }
104 
setId(std::string id)105             void setId( std::string id ) { m_id = id; }
setLocalName(std::string localName)106             void setLocalName( std::string localName ) { m_localName = localName; }
setLocalNamespace(std::string localNamespace)107             void setLocalNamespace( std::string localNamespace ) { m_localNamespace = localNamespace; }
setDisplayName(std::string displayName)108             void setDisplayName( std::string displayName ) { m_displayName = displayName; }
setQueryName(std::string queryName)109             void setQueryName( std::string queryName ) { m_queryName = queryName; }
setType(Type type)110             void setType( Type type ) { m_type = type; }
setMultiValued(bool multivalued)111             void setMultiValued( bool multivalued ) { m_multiValued = multivalued; }
setUpdatable(bool updatable)112             void setUpdatable( bool updatable ) { m_updatable = updatable; }
setInherited(bool inherited)113             void setInherited( bool inherited ) { m_inherited = inherited; }
setRequired(bool required)114             void setRequired( bool required ) { m_required = required; }
setQueryable(bool queryable)115             void setQueryable( bool queryable ) { m_queryable = queryable; }
setOrderable(bool orderable)116             void setOrderable( bool orderable ) { m_orderable = orderable; }
setOpenChoice(bool openChoice)117             void setOpenChoice( bool openChoice ) { m_openChoice = openChoice; }
118 
119             void setTypeFromXml( std::string typeStr );
120             void setTypeFromJsonType( std::string jsonType );
121 
122             void update( std::vector< ObjectTypePtr > typesDefs );
123     };
124     typedef boost::shared_ptr< PropertyType > PropertyTypePtr;
125 }
126 
127 #endif
128