#include "CppBase.h" #include "Internal.h" namespace Upp { #define LLOG(x) #define LTIMING(x) DTIMING(x) void CppItem::Serialize(Stream& s) { s % kind % access % item % name % natural % at % tparam % param % pname % tname % ctname % type % ptype % virt % filetype % file % line % impl % using_namespaces; } struct CmpItem { bool operator()(const CppItem& a, const String& b) const { return a.qitem < b; } }; int FindItem(const Array& x, const String& qitem) { for(int i = 0; i < x.GetCount(); i++) if(x[i].qitem == qitem) return i; return -1; } int FindNext(const Array& x, int i) { if(i >= x.GetCount()) return i; String q = x[i].qitem; while(i < x.GetCount() && x[i].qitem == q) i++; return i; } int GetCount(const Array& x, int i) { return FindNext(x, i) - i; } int FindName(const Array& x, const String& name, int i) { while(i < x.GetCount()) { if(x[i].name == name) return i; i++; } return -1; } bool CppBase::IsType(int i) const { return GetKey(i).GetCount(); } void CppBase::Dump(Stream& s) { for(int i = 0; i < GetCount(); i++) { s << Nvl(GetKey(i), "<>") << "\n"; const Array& m = (*this)[i]; for(int j = 0; j < m.GetCount(); j++) s << '\t' << m[j] << "\n"; } } void CppBase::Sweep(const Index& file, bool keep) { Vector remove; for(int ni = 0; ni < GetCount(); ni++) { Array& n = (*this)[ni]; Vector nr; for(int i = 0; i < n.GetCount(); i++) if((file.Find(n[i].file) < 0) == keep) nr.Add(i); if(nr.GetCount() == n.GetCount()) remove.Add(ni); // remove whole array (later) else n.Remove(nr); // only remove some items } Remove(remove); } void CppBase::Append(CppBase&& base) { for(int i = 0; i < base.GetCount(); i++) GetAdd(base.GetKey(i)).Append(pick(base[i])); } void CppBase::RemoveFile(int filei) { Index h; h.Add(filei); RemoveFiles(h); } }