#ifndef _VAR_DEQUE_ #define _VAR_DEQUE_ #include #if _STL_COMPILER_PREPROCESSOR #include <__msvc_filebuf.hpp> #include #include #include "var.h" #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new _STD_BEGIN _EXPORT_STD class varDeque : public var { protected: map listVal; bool listSet = (type == "varList"); bool dict = (type == "dictionary"); void set(string word) { double worth = 0; text = word; type = "std::string"; for (int i = 0; i < word.length() && 4 + 3 * i < 94; i++) worth += word[i] * pow(10, -3 * i); value = worth; } void set(char c) { text = "" + c; type = "char"; value = c; } void set(bool b) { if (b) text = "\"true\""; else text = "\"false\""; type = "bool"; value = b; } void set(int i) { text = to_string(i); type = "int"; value = i; } void set(float f) { text = to_string(f); type = "float"; value = f; } void set(double d) { text = to_string(d); type = "double"; value = d; } void set(list value) { listVal = {}; type = "varList"; for (int i = 0; i < value.size(); i++) { list::iterator find = value.begin(); var current = i; for (int j = 0; j < i; j++) find++; listVal.insert(current, *find); } text = ""; varDeque::value = 0.0; } void set(map value) { listVal = value; type = "dictionary"; text = ""; varDeque::value = 0.0; } public: // Value Output Functions varDeque(string value = "") { set(value); } varDeque(char c) { set(c); } varDeque(bool b) { set(b); } varDeque(int i) { set(i); } varDeque(float f) { set(f); } varDeque(double d) { set(d); } varDeque(list l) { set(l); } varDeque(map m) { set(m); } int size() { if (type == "varList" || type == "dictionary") return listVal.size(); else return 1; } // Operator Assignment Functions varDeque operator=(list value) { set(value); return *this; } varDeque operator=(map value) { set(value); return *this; } // List Member Functions /* Bracket Operator with a Var */ var& operator[](var value) { object_type_error typeError("The varDeque cannot use value brackets with any non-dictionary type."); out_of_range rangeError("This location does not exist for the type varDeque."); if (type != "dictionary") throw typeError; if (listVal[value] == map::empty) throw rangeError; return listVal[value]; } /* Bracket Operator with an Int */ var& operator[](int i) { out_of_range rangeError("The varDeque does not go to the desired location."); if (type == "dictionary" || type == "varList") { if (type == "varList" && (i < 0 || i >= listVal.size())) throw rangeError; var value = i; return listVal[value]; } if (i < 0 || i >= text.length()) throw rangeError; var value = text[i]; return value; } /* Bracket Operator with a String */ var& operator[](string text) { var value = text; object_type_error typeError("The varDeque cannot use value brackets with any non-dictionary type."); out_of_range rangeError("This location does not exist for the type varDeque."); if (type != "dictionary") throw typeError; if (listVal[value] == map::empty) throw rangeError; return listVal[value]; } /* Bracket Operator with a Char */ var& operator[](char c) { var value = c; object_type_error typeError("The varDeque cannot use value brackets with any non-dictionary type."); out_of_range rangeError("This location does not exist for the type varDeque."); if (type != "dictionary") throw typeError; if (listVal[value] == map::empty) throw rangeError; return listVal[value]; } /* Bracket Operator with a Bool */ var& operator[](bool b) { var value = b; object_type_error typeError("The varDeque cannot use value brackets with any non-dictionary type."); out_of_range rangeError("This location does not exist for the type varDeque."); if (type != "dictionary") throw typeError; if (listVal[value] == map::empty) throw rangeError; return listVal[value]; } /* Bracket Operator with a Float */ var& operator[](float f) { var value = f; object_type_error typeError("The varDeque cannot use value brackets with any non-dictionary type."); out_of_range rangeError("This location does not exist for the type varDeque."); if (type != "dictionary") throw typeError; if (listVal[value] == map::empty) throw rangeError; return listVal[value]; } /* Bracket Operator with a Double */ var& operator[](double d) { var value = d; object_type_error typeError("The varDeque cannot use value brackets with any non-dictionary type."); out_of_range rangeError("This location does not exist for the type varDeque."); if (type != "dictionary") throw typeError; if (listVal[value] == map::empty) throw rangeError; return listVal[value]; } // Return Value Functions operator double() { if (type == "varList" || type == "dictionary") { var value = 0; map::iterator find = listVal.begin(); for (int i = 0; i < listVal.size(); i++) { pair value = *find; value += value.second; } } else return value; } }; _STD_END #ifdef _VALUE_SUPPORTS_EXPERIMENTAL_FILESYSTEM #undef _VALUE_SUPPORTS_EXPERIMENTAL_FILESYSTEM #endif #pragma pop_macro("new") _STL_RESTORE_CLANG_WARNINGS #pragma warning(pop) #pragma pack(pop) #endif // _STL_COMPILER_REPROCESSOR_ #endif // _VAR_DEQUE