2 * \file storage_value.h
4 * \date 2012-08-18 15:00GMT
5 * \author Jan Boon (Kaetemi)
10 * Copyright (C) 2012 by authors
12 * This file is part of RYZOM CORE PIPELINE.
13 * RYZOM CORE PIPELINE is free software: you can redistribute it
14 * and/or modify it under the terms of the GNU Affero General Public
15 * License as published by the Free Software Foundation, either
16 * version 3 of the License, or (at your option) any later version.
18 * RYZOM CORE PIPELINE is distributed in the hope that it will be
19 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Affero General Public License for more details.
23 * You should have received a copy of the GNU Affero General Public
24 * License along with RYZOM CORE PIPELINE. If not, see
25 * <http://www.gnu.org/licenses/>.
28 #ifndef PIPELINE_STORAGE_VALUE_H
29 #define PIPELINE_STORAGE_VALUE_H
30 #include <nel/misc/types_nl.h>
35 #include <nel/misc/ucstring.h>
36 #include <nel/misc/string_common.h>
39 #include "storage_object.h"
45 class CStorageValue
: public IStorageObject
53 virtual std::string
className() const;
54 virtual void serial(NLMISC::IStream
&stream
);
55 virtual void toString(std::ostream
&ostream
, const std::string
&pad
= "") const;
57 public: // should be protected but that doesn't compile, nice c++!
58 // Sets size when reading
59 virtual void setSize(sint32 size
);
60 // Gets the size when writing, return false if unknown
61 virtual bool getSize(sint32
&size
) const;
65 std::string CStorageValue
<T
>::className() const
67 return "CStorageValue";
71 void CStorageValue
<T
>::serial(NLMISC::IStream
&stream
)
77 void CStorageValue
<std::string
>::serial(NLMISC::IStream
&stream
);
80 void CStorageValue
<ucstring
>::serial(NLMISC::IStream
&stream
);
83 void CStorageValue
<T
>::toString(std::ostream
&ostream
, const std::string
&pad
) const
85 std::string s
= NLMISC::toString(Value
);
86 ostream
<< "(" << className() << ") { " << s
<< " } ";
90 void CStorageValue
<ucstring
>::toString(std::ostream
&ostream
, const std::string
&pad
) const;
93 void CStorageValue
<T
>::setSize(sint32 size
)
95 if (size
!= sizeof(Value
))
96 nlerror("Size does not match value type");
97 IStorageObject::setSize(size
);
101 void CStorageValue
<std::string
>::setSize(sint32 size
);
104 void CStorageValue
<ucstring
>::setSize(sint32 size
);
106 template <typename T
>
107 bool CStorageValue
<T
>::getSize(sint32
&size
) const
109 size
= sizeof(Value
);
114 bool CStorageValue
<std::string
>::getSize(sint32
&size
) const;
117 bool CStorageValue
<ucstring
>::getSize(sint32
&size
) const;
119 } /* namespace MAX */
120 } /* namespace PIPELINE */
122 #endif /* #ifndef PIPELINE_STORAGE_VALUE_H */