160 lines
3.6 KiB
C++
160 lines
3.6 KiB
C++
/*
|
|
* This file is a part of EZC -- Easy templating in C++ library
|
|
* and is distributed under the BSD 3-Clause licence.
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
*/
|
|
|
|
/*
|
|
* Copyright (c) 2021, Tomasz Sowa
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions are met:
|
|
*
|
|
* * Redistributions of source code must retain the above copyright notice,
|
|
* this list of conditions and the following disclaimer.
|
|
*
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
*
|
|
* * Neither the name Tomasz Sowa nor the names of contributors to this
|
|
* project may be used to endorse or promote products derived
|
|
* from this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
#ifndef headerfile_ezc_var
|
|
#define headerfile_ezc_var
|
|
|
|
#include "spacewrapper.h"
|
|
#include "date/date.h"
|
|
#include "modelcontainerwrapper.h"
|
|
#include "textstream/textstream.h"
|
|
|
|
|
|
|
|
namespace Ezc
|
|
{
|
|
|
|
|
|
/*
|
|
a variable
|
|
*/
|
|
class Var
|
|
{
|
|
public:
|
|
|
|
|
|
enum Type
|
|
{
|
|
// string or wstring from space_local
|
|
TYPE_VOID,
|
|
TYPE_BOOL,
|
|
TYPE_LONG,
|
|
TYPE_STRING,
|
|
TYPE_STREAM,
|
|
|
|
TYPE_FUNCTION,
|
|
|
|
TYPE_MODEL,
|
|
TYPE_MODEL_CONTAINER_WRAPPER,
|
|
TYPE_SPACE_WRAPPER, // or just type_space
|
|
|
|
};
|
|
|
|
Type type;
|
|
|
|
Var();
|
|
|
|
void clear();
|
|
|
|
|
|
bool to_bool() const;
|
|
|
|
|
|
void set(bool val);
|
|
void set(const char * str);
|
|
void set(const wchar_t * str);
|
|
void set(const std::string & str);
|
|
void set(const std::wstring & str);
|
|
|
|
void set_function(const std::wstring & str);
|
|
|
|
bool is_equal(const char * str) const;
|
|
bool is_equal(const wchar_t * str) const;
|
|
|
|
bool is_equal(const std::string & str) const;
|
|
bool is_equal(const std::wstring & str) const;
|
|
|
|
void serialize_to(pt::WTextStream & str);
|
|
|
|
|
|
Var & operator<<(const char * str);
|
|
Var & operator<<(const wchar_t * str);
|
|
Var & operator<<(const std::string & str);
|
|
Var & operator<<(const std::wstring & str);
|
|
// add the rest of << operators...
|
|
|
|
|
|
morm::Model * model;
|
|
morm::ModelContainerWrapper * model_container_wrapper;
|
|
pt::Date * date;
|
|
morm::SpaceWrapper * space_wrapper;
|
|
|
|
|
|
|
|
//pt::Space * space;
|
|
|
|
|
|
pt::Space space_local;
|
|
pt::WTextStream stream;
|
|
|
|
|
|
private:
|
|
|
|
bool to_bool_str() const;
|
|
|
|
bool is_equal_bool(const char * str) const;
|
|
bool is_equal_string(const char * str) const;
|
|
|
|
bool is_equal_bool(const wchar_t * str) const;
|
|
bool is_equal_string(const wchar_t * str) const;
|
|
|
|
|
|
|
|
/*
|
|
* old
|
|
*/
|
|
|
|
|
|
/*
|
|
* if true then means 'str' is a function name and should be called (res is ignored)
|
|
*
|
|
* if false then means 'str' is a string value and res is a boolean value
|
|
*/
|
|
//bool is_function;
|
|
|
|
//std::wstring str; // a string value
|
|
//bool res; // a boolean value
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|