[170] | 1 | #pragma once
|
---|
| 2 |
|
---|
[181] | 3 | #include <string>
|
---|
| 4 | #include <vector>
|
---|
| 5 |
|
---|
[170] | 6 | #include "Type.h"
|
---|
| 7 | #include "BasicFixed.h"
|
---|
| 8 |
|
---|
| 9 | class Parameter : public Type
|
---|
| 10 | {
|
---|
[181] | 11 | std::string varName;
|
---|
[170] | 12 | bool isRef;
|
---|
| 13 | bool isArray;
|
---|
| 14 | int subScripts[MAX_ARRAYDIM];
|
---|
| 15 |
|
---|
[181] | 16 | const std::string initValue;
|
---|
[170] | 17 |
|
---|
[203] | 18 | // XMLシリアライズ用
|
---|
| 19 | private:
|
---|
| 20 | friend class boost::serialization::access;
|
---|
| 21 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
| 22 | {
|
---|
| 23 | ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Type );
|
---|
| 24 | ar & BOOST_SERIALIZATION_NVP( varName );
|
---|
| 25 | ar & BOOST_SERIALIZATION_NVP( isRef );
|
---|
| 26 | ar & BOOST_SERIALIZATION_NVP( isArray );
|
---|
| 27 | ar & BOOST_SERIALIZATION_NVP( subScripts );
|
---|
| 28 | ar & BOOST_SERIALIZATION_NVP( initValue );
|
---|
| 29 | }
|
---|
| 30 |
|
---|
[170] | 31 | public:
|
---|
[181] | 32 | Parameter( const std::string &varName, const Type &type, bool isRef = false, const std::string initValue = "" ):
|
---|
[170] | 33 | Type( type ),
|
---|
| 34 | varName( varName ),
|
---|
| 35 | isRef( isRef ),
|
---|
| 36 | isArray( false ),
|
---|
| 37 | initValue( initValue )
|
---|
| 38 | {
|
---|
| 39 | subScripts[0] = -1;
|
---|
| 40 | }
|
---|
| 41 | Parameter( const Parameter ¶m ):
|
---|
| 42 | Type( param ),
|
---|
| 43 | varName( param.varName ),
|
---|
| 44 | isRef( param.isRef ),
|
---|
| 45 | isArray( false ),
|
---|
| 46 | initValue( param.initValue )
|
---|
| 47 | {
|
---|
| 48 | subScripts[0] = -1;
|
---|
| 49 | if( param.isArray ){
|
---|
| 50 | SetArray( param.subScripts );
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 | ~Parameter(){}
|
---|
| 54 |
|
---|
| 55 | void SetArray( const int *pSubScripts ){
|
---|
| 56 | isArray = true;
|
---|
| 57 | memcpy( this->subScripts, pSubScripts, sizeof(int) * MAX_ARRAYDIM );
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[181] | 60 | const std::string &GetVarName() const
|
---|
[170] | 61 | {
|
---|
| 62 | return varName;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | bool IsRef() const
|
---|
| 66 | {
|
---|
| 67 | return isRef;
|
---|
| 68 | }
|
---|
| 69 | bool IsArray(){
|
---|
| 70 | return isArray;
|
---|
| 71 | }
|
---|
| 72 | int *GetSubScriptsPtr(){
|
---|
| 73 | return subScripts;
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[181] | 76 | const std::string &GetInitValue() const
|
---|
[170] | 77 | {
|
---|
| 78 | return initValue;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | bool Equals( const Parameter ¶m ) const
|
---|
| 82 | {
|
---|
| 83 | if( Type::Equals( param ) ){
|
---|
| 84 | return true;
|
---|
| 85 | }
|
---|
| 86 | else{
|
---|
| 87 |
|
---|
| 88 | if( this->isRef && this->GetBasicType() == DEF_ANY &&
|
---|
| 89 | param.isRef == false && param.IsPointer()
|
---|
| 90 | ||
|
---|
| 91 | this->isRef == false && this->IsPointer() &&
|
---|
| 92 | param.isRef && param.GetBasicType() == DEF_ANY ){
|
---|
| 93 | /* ByRef var As Any
|
---|
| 94 | と
|
---|
| 95 | var As VoidPtr
|
---|
| 96 | は同等
|
---|
| 97 | */
|
---|
| 98 | return true;
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | return false;
|
---|
| 103 | }
|
---|
| 104 | };
|
---|
| 105 |
|
---|
[181] | 106 | class Parameters : public std::vector<Parameter *>
|
---|
[170] | 107 | {
|
---|
[203] | 108 | // XMLシリアライズ用
|
---|
| 109 | private:
|
---|
| 110 | friend class boost::serialization::access;
|
---|
| 111 | template<class Archive> void serialize(Archive& ar, const unsigned int version)
|
---|
| 112 | {
|
---|
| 113 | ar & boost::serialization::make_nvp("vector_Parameter", boost::serialization::base_object<vector<Parameter *>>(*this));
|
---|
| 114 | }
|
---|
| 115 |
|
---|
[170] | 116 | public:
|
---|
| 117 |
|
---|
| 118 | bool Equals( const Parameters ¶ms ) const
|
---|
| 119 | {
|
---|
| 120 | if( this->size() != params.size() ){
|
---|
| 121 | return false;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | int max = (int)this->size();
|
---|
| 125 | for( int i=0; i<max; i++ ){
|
---|
| 126 | if( !(*this)[i]->Equals( *params[i] ) ){
|
---|
| 127 | return false;
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | return true;
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | int GetMemorySize() const
|
---|
| 135 | {
|
---|
| 136 | return (int)this->size() * PTR_SIZE;
|
---|
| 137 | }
|
---|
| 138 | };
|
---|