MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / getContents

Method getContents

src/Base/ParameterPy.cpp:807–869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

805}
806
807Py::Object ParameterGrpPy::getContents(const Py::Tuple& args)
808{
809 if (!PyArg_ParseTuple(args.ptr(), "")) {
810 throw Py::Exception();
811 }
812
813 if (_cParamGrp->IsEmpty()) {
814 return Py::None();
815 }
816
817 Py::List list;
818 // filling up Text nodes
819 std::vector<std::pair<std::string, std::string>> mcTextMap = _cParamGrp->GetASCIIMap();
820 for (const auto& it : mcTextMap) {
821 Py::Tuple t2(3);
822 t2.setItem(0, Py::String("String"));
823 t2.setItem(1, Py::String(it.first.c_str()));
824 t2.setItem(2, Py::String(it.second.c_str()));
825 list.append(t2);
826 }
827
828 // filling up Int nodes
829 std::vector<std::pair<std::string, long>> mcIntMap = _cParamGrp->GetIntMap();
830 for (const auto& it : mcIntMap) {
831 Py::Tuple t3(3);
832 t3.setItem(0, Py::String("Integer"));
833 t3.setItem(1, Py::String(it.first.c_str()));
834 t3.setItem(2, Py::Long(it.second));
835 list.append(t3);
836 }
837
838 // filling up Float nodes
839 std::vector<std::pair<std::string, double>> mcFloatMap = _cParamGrp->GetFloatMap();
840 for (const auto& it : mcFloatMap) {
841 Py::Tuple t4(3);
842 t4.setItem(0, Py::String("Float"));
843 t4.setItem(1, Py::String(it.first.c_str()));
844 t4.setItem(2, Py::Float(it.second));
845 list.append(t4);
846 }
847
848 // filling up bool nodes
849 std::vector<std::pair<std::string, bool>> mcBoolMap = _cParamGrp->GetBoolMap();
850 for (const auto& it : mcBoolMap) {
851 Py::Tuple t5(3);
852 t5.setItem(0, Py::String("Boolean"));
853 t5.setItem(1, Py::String(it.first.c_str()));
854 t5.setItem(2, Py::Boolean(it.second));
855 list.append(t5);
856 }
857
858 // filling up UInt nodes
859 std::vector<std::pair<std::string, unsigned long>> mcUIntMap = _cParamGrp->GetUnsignedMap();
860 for (const auto& it : mcUIntMap) {
861 Py::Tuple t6(3);
862 t6.setItem(0, Py::String("Unsigned Long"));
863 t6.setItem(1, Py::String(it.first.c_str()));
864 t6.setItem(2, Py::Long(it.second));

Callers

nothing calls this directly

Calls 11

GetASCIIMapMethod · 0.80
GetIntMapMethod · 0.80
GetFloatMapMethod · 0.80
GetBoolMapMethod · 0.80
GetUnsignedMapMethod · 0.80
StringClass · 0.70
ExceptionClass · 0.50
ptrMethod · 0.45
IsEmptyMethod · 0.45
c_strMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected