void BPlusTree::exportToPlainText(string filePath, bool keytext, bool textContent){ // serveto's way ofstream salida(filePath.c_str(),ios::out | ios::trunc); salida << "--------- Arbol B+ ---------" << endl << endl; salida << "Tamanio Total Nodo: " << TreeConstraits::getFullSizeNode() << endl; salida << "Tamanio Datos Control Nodo: " << TreeConstraits::getControlSizeNode() << endl; salida << "Tamanio Efectivo Nodo: " << TreeConstraits::getEfectiveSizeNode() << endl; salida << "Tamanio Datos Control Registro: " << TreeConstraits::getControlSizeRecord() << endl << endl; salida << "Primera Hoja: " << firstLeaf << endl; salida << "Nodos Libres: "; vector<int>::iterator it = freeNodes.begin(); while (it != freeNodes.end()) { int numeroDeNodo = *it; salida << numeroDeNodo << " | "; it++; } salida << endl; if (root) exportNode(salida, root, 1,keytext,textContent); salida.close(); }
void exportNode(iwriter & writer, Node * node) { const char * name = typeid(*node).name(); writer.putString(name); node->exportTo(writer); writer.put(node->children().size()); //LOGE("Exporting node with type %s with %d children", name, node->children().size()); for (auto & child : node->children()) exportNode(writer, child); }
StreamEncoder & exportTo(iwriter & writer) { writer.put(-1); if (_root == nullptr) { //LOGE("Has no root :("); writer.put(0); } else { //LOGE("Has root, exporting!"); writer.put(1); exportNode(writer, _root); } writer.put(-1); return *this; }
void PECOFFLinkingContext::createImplicitFiles( std::vector<std::unique_ptr<File>> &) { std::vector<std::unique_ptr<Node>> &members = getNodes(); // Create a file for the entry point function. std::unique_ptr<FileNode> entry(new FileNode( llvm::make_unique<pecoff::EntryPointFile>(*this))); members.insert(members.begin() + getGroupStartPos(members), std::move(entry)); // Create a file for __ImageBase. std::unique_ptr<FileNode> fileNode(new FileNode( llvm::make_unique<pecoff::LinkerGeneratedSymbolFile>(*this))); members.push_back(std::move(fileNode)); // Create a file for _imp_ symbols. std::unique_ptr<FileNode> impFileNode(new FileNode( llvm::make_unique<pecoff::LocallyImportedSymbolFile>(*this))); members.push_back(std::move(impFileNode)); // Create a file for dllexported symbols. std::unique_ptr<FileNode> exportNode(new FileNode( llvm::make_unique<pecoff::ExportedSymbolRenameFile>(*this))); addLibraryFile(std::move(exportNode)); }
void BPlusTree::exportNode(ofstream& salida, Node* unNodo, int tabulacion,bool keyText,bool textContent) { if (unNodo->isLeaf()) { LeafNode *unNodoHoja = static_cast<LeafNode*> (unNodo); salida << endl; for(int i = 0 ; i < tabulacion ; i++) salida << " "; salida << "Numero: " << unNodoHoja->number << " Nivel: " << unNodoHoja->level << " Cant.Elem: " << unNodoHoja->keyMount << " Esp.Libre: " << TreeConstraits::getEfectiveSizeNode() - unNodoHoja->occupiedSpace << " Hoja.Sig: " << unNodoHoja->nextLeaf << endl; for (int posicion = 0; posicion < unNodoHoja->keyMount; ++posicion) { for(int i = 0 ; i < tabulacion + 4 ; i++) salida << " "; salida << "("; Key unaClave = unNodoHoja->keys[posicion]; if(keyText) { salida << unaClave.toString(); } else { ByteString clave(unaClave.toString()); salida << Utility::toString(clave.readAsInt(0)); } salida << ";"; ByteString unDato = unNodoHoja->byteData[posicion]; if(textContent) { salida << unDato.toString(); } else { salida << Utility::intToString(unDato.readAsInt(0)); } salida << ")"; salida << (unaClave.getSize() + unDato.getSize() + TreeConstraits::getControlSizeRecord()) << endl; } salida << endl; } else { InnerNode *unNodoInterior = static_cast<InnerNode*> (unNodo); salida << endl << endl; for(int i=0; i<tabulacion ; i++) salida << " "; salida << "Numero: " << unNodoInterior->number << " Nivel: " << unNodoInterior->level << " Cant.Elem: " << unNodoInterior->keyMount << " Esp.Libre: " << TreeConstraits::getEfectiveSizeNode() - unNodoInterior->occupiedSpace << endl; for (int posicion = 0; posicion <= unNodoInterior->keyMount; ++posicion) { if (posicion < unNodoInterior->keyMount) { Key unaClave = unNodoInterior->keys[posicion]; for(int i=0; i<(tabulacion+1) ; i++) salida << " "; salida << "("; if(keyText) { salida << unaClave.toString(); } else { ByteString clave(unaClave.toString()); salida << Utility::toString(clave.readAsInt(0)); } salida << ")"; salida << unaClave.getSize(); salida << " "; salida << unNodoInterior->getSons()[posicion] << " "; } } for (int posicion = 0; posicion <= unNodoInterior->keyMount; ++posicion) { Node *hijo = hidratateNode(unNodoInterior->sons[posicion]); exportNode(salida, hijo, tabulacion + 2,keyText,textContent); if (hijo) freeNodeMemory(hijo); } for(int i=0; i<tabulacion ; i++) salida << " "; salida << endl; } }
/* ==================== exportNode ==================== */ void G3DAExport::exportNode( INode* i_node, NODE* parent ) { // if it is hidden? bool include = false; if(!i_node->IsHidden()) include = true; // get the result of the pipeline at the current time Object *obj = i_node->EvalWorldState(mTime).obj; if(obj) { if(obj->ClassID() == Class_ID(TARGET_CLASS_ID, 0)) include = false; if(obj->ClassID() == Class_ID(0x74f93b07, 0x1eb34300)) include = false; if(obj->ClassID() == Class_ID(BOXOBJ_CLASS_ID, 0)) include = false; if(obj->ClassID() == Class_ID(SPHERE_CLASS_ID, 0)) include = false; if(obj->ClassID() == Class_ID(CYLINDER_CLASS_ID, 0)) include = false; if(obj->ClassID() == Class_ID(CONE_CLASS_ID, 0)) include = false; if(obj->SuperClassID() == CAMERA_CLASS_ID) include = false; if(obj->SuperClassID() == LIGHT_CLASS_ID) include = false; if(obj->SuperClassID() == SHAPE_CLASS_ID) include = false; } // if this node is renderable? if(include) { if(getModifier(i_node,Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B)) != NULL) { include = false; } if(getModifier(i_node,SKIN_CLASSID) != NULL) { mSkins.push_back(i_node); include = false; } } // the new node NODE* this_node = new NODE; MAX_CHECK(this_node); if(parent==NULL) { mRoot = this_node; } else { parent->children.push_back(this_node); this_node->parent = parent; } this_node->i_node = i_node; this_node->include = include; this_node->name = i_node->GetName(); if(this_node->include) { NODE* parent = this_node->parent; while(parent) { parent->include = true; parent = parent->parent; } } // process the child node for(int i = 0; i < i_node->NumberOfChildren(); i++) { exportNode(i_node->GetChildNode(i),this_node); } }
/* ==================== DoExport ==================== */ int G3DAExport::DoExport(const TCHAR *name, ExpInterface *ei, Interface *i, BOOL suppressPrompts, DWORD options) { // clear the old data if(mRoot){delete mRoot, mRoot = NULL;} mNodeCount = 0; mSkins.clear(); // normalize the file path Str path = UnifySlashes(name); // get the export dir mPath = UnifySlashes(i->GetDir(APP_EXPORT_DIR)); mPath += '/'; if( !strstr( path.c_str(), mPath.c_str() ) ) { G3DAssert("The export path(%s) is illegal!",name); return 1; } // get the animation range Interval inter = i->GetAnimRange(); mTime = i->GetTime(); mStart = inter.Start(); mEnd = inter.End(); // recursive export all of the node exportNode(i->GetRootNode()); // export all of the skin for(int k = 0; k < mSkins.size(); k++) exportSkin(mSkins[k]); // recursive export all of the animation exportAnimation(mRoot); // check all of the nodes std::set<Str> names, duplicates; check(mRoot, names, duplicates); for(std::set<Str>::iterator it = duplicates.begin(); it != duplicates.end(); ++it) { G3DAssert( "Duplicate node name : %s", (*it).c_str() ); return 1; } #if 0 // write all of the data FILE *output = fopen(path.c_str(), "wb"); if(output==NULL) { G3DAssert("Fail to open the file : %s", path.c_str()); return 1; } // write count of the frame unsigned int frame_count = (mEnd-mStart)/GetTicksPerFrame()+1; fwrite( &frame_count, sizeof(unsigned int), 1, output ); // write number of the node fwrite( &mNodeCount, sizeof(unsigned int), 1, output ); // write count of the action unsigned int action_count = 0; fwrite( &action_count, sizeof(unsigned int), 1, output ); // write all of the node animation wirteAnimation(output,mRoot); // close file fclose(output); #else // write all of the data FILE *output = fopen(path.c_str(), "wb"); if(output==NULL) { G3DAssert("Fail to open the file : %s", path.c_str()); return 1; } // get the count of the frame unsigned int frame_count = (mEnd-mStart)/GetTicksPerFrame()+1; // begin to write the animation fprintf(output, "<animation>\n"); // begin to write the frame fprintf(output, "<frame count=\"%d\">\n", frame_count); // write all of the node frame wirteFrame(output,mRoot); // end to wirte the frame fprintf(output, "</frame>\n"); // end to wirte the animation fprintf(output, "</animation>\n"); // close file fclose(output); #endif // clear all of the data mSkins.clear(); if(mRoot){delete mRoot, mRoot = NULL;} return 1; }
void ClassifBPlusTree::exportNode(ofstream& salida, Node* unNodo, int tabulacion,bool keytext, bool textContent) { if (unNodo->isLeaf()) { LeafNode *unNodoHoja = static_cast<LeafNode*> (unNodo); salida << endl; for(int i = 0 ; i < tabulacion ; i++) salida << " "; salida << "Numero: " << unNodoHoja->number << " Nivel: " << unNodoHoja->level << " Cant.Elem: " << unNodoHoja->keyMount << " Esp.Libre: " << TreeConstraits::getEfectiveSizeNode() - unNodoHoja->occupiedSpace << " Hoja.Sig: " << unNodoHoja->nextLeaf << endl; for (int posicion = 0; posicion < unNodoHoja->keyMount; ++posicion) { for(int i = 0 ; i < tabulacion + 4 ; i++) salida << " "; salida << "("; Key unaClave = unNodoHoja->keys[posicion]; if(keytext) { salida << unaClave.toString(); } else { ByteString clave(unaClave.toString()); if(clave.getSize()==(2*sizeof(int))) { salida << Utility::toString(clave.readAsInt(0)); salida << "-"; salida << Utility::toString(clave.readAsInt(sizeof(int))); } else salida << Utility::toString(clave.readAsInt(0)); } salida << ";"; ByteString unDato = unNodoHoja->byteData[posicion]; int idBlock = unDato.readAsInt(0); string datoString = Utility::intToString(idBlock); salida << datoString; salida << ")"; salida << (unaClave.getSize() + unDato.getSize() + TreeConstraits::getControlSizeRecord()) << endl; for(int i = 0 ; i < tabulacion + 4 ; i++) salida << " "; ListofID listOfID(this->fileBlockManager,idBlock); list<int> listOfInt = listOfID.getListID(); list<int>::iterator it; int id; //int count = 0; ByteString bs; unsigned int i = 0; for(it=listOfInt.begin();it!=listOfInt.end();++it) { i++; id = *it; bs.insertLast(Utility::intToString(id)); bs.insertLast(" "); if((i == listOfInt.size()) || (bs.toString().size() >80)) { salida << bs.toString(); salida << endl; if(i != listOfInt.size()) { for(int i = 0 ; i < tabulacion + 4 ; i++) salida << " "; } bs.clean(); } } } } else { InnerNode *unNodoInterior = static_cast<InnerNode*> (unNodo); salida << endl << endl; for(int i=0; i<tabulacion ; i++) salida << " "; salida << "Numero: " << unNodoInterior->number << " Nivel: " << unNodoInterior->level << " Cant.Elem: " << unNodoInterior->keyMount << " Esp.Libre: " << TreeConstraits::getEfectiveSizeNode() - unNodoInterior->occupiedSpace << endl; for (int posicion = 0; posicion <= unNodoInterior->keyMount; ++posicion) { if (posicion < unNodoInterior->keyMount) { Key unaClave = unNodoInterior->keys[posicion]; for(int i=0; i<(tabulacion+1) ; i++) salida << " "; salida << "("; if(keytext) { salida << unaClave.toString(); } else { ByteString clave(unaClave.toString()); salida << Utility::toString(clave.readAsInt(0)); } salida << ")"; salida << unaClave.getSize(); salida << " "; salida << unNodoInterior->getSons()[posicion] << " "; } } for (int posicion = 0; posicion <= unNodoInterior->keyMount; ++posicion) { Node *hijo = hidratateNode(unNodoInterior->sons[posicion]); exportNode(salida, hijo, tabulacion + 2,keytext,textContent); if (hijo) freeNodeMemory(hijo); } for(int i=0; i<tabulacion ; i++) salida << " "; salida << endl; } }