void LayoutTableLoad::executePlanOperation() { const auto &input = this->input.getTable(0); if ((input->columnCount() >= 1) && (input->size() >= _input_row)) { std::string tmp_table_description = input->getValue<std::string>(0, _input_row); std::vector<std::string> description_lines; splitString(description_lines, tmp_table_description, "\n"); if (_override_group != "") { std::vector<std::string> group_lines; splitString(group_lines, description_lines[2], "|"); for (size_t index = 0; index < group_lines.size(); ++index) { if (_override_group == "C") group_lines[index] = std::to_string(index) + "_C"; else if (_override_group == "R") group_lines[index] = "0_R"; else throw std::runtime_error("unknown override_group " + _override_group); } description_lines[2] = joinString(group_lines, "|"); } std::string table_description = joinString(description_lines, "\n"); StringHeader header(table_description); CSVInput input(_file_name, CSVInput::params().setCSVParams(csv::HYRISE_FORMAT)); StorageManager *sm = StorageManager::getInstance(); sm->loadTable(_table_name, Loader::params().setHeader(header).setInput(input)); addResult(sm->getTable(_table_name)); } else { throw std::runtime_error("Input of LayoutTableLoad doesn't have at least one field to begin with"); } }
TYPED_TEST(HashTableTest, test_column_combinations) { hyrise::storage::atable_ptr_t table = Loader::shortcuts::load("test/tables/hash_table_test.tbl"); for (auto & cols: combinations) { SCOPED_TRACE(joinString(cols, ",")); EXPECT_TRUE(TestCoverage<TypeParam>(table, cols)); } }
int Markovsky::LearnLine(string &line) { // Ignore quotes if (isdigit(line[0])) return false; if (line[0] == '<') return false; if (line[0] == '[') return false; vector<string> curwords; tokenizeString(line, curwords); string cleanline = joinString(curwords); if (lines.find(cleanline) != lines.end()) return false; set<string>::iterator lineit = lines.insert(cleanline).first; int sz = curwords.size(); for (int i = 0; i < sz; i++) { map<string, word_t>::iterator wit = words.find(curwords[i]); if (wit == words.end()) { word_t cword; context_t cxt(lineit, i); cword.push_back(cxt); words[curwords[i]] = cword; } else { context_t cxt(lineit, i); ((*wit).second).push_back(cxt); } num_contexts++; } return true; }
TxElement* util::xmlGetElement(TxElement* node, std::string path) { std::vector<std::string> parts = splitString(path, '/'); if (parts.size() > 0) { std::vector<std::string> components = splitString(parts[0], '&'); std::string name = components[0]; ticpp::Iterator<ticpp::Element> child; for (child = child.begin(node); child != child.end(); child++) { bool match = true; std::string childname; child->GetValue(&childname); if (childname == name) { for (size_t i = 1; i < components.size(); ++i) { std::vector<std::string> pair = splitString(components[i], '='); match = match && child->GetAttributeOrDefault(pair[0], "") == pair[1]; } } else { match = false; } if (match) { if (parts.size() > 1) { return xmlGetElement(child.Get(), joinString(parts.begin() + 1, parts.end(), "/")); } else { return child.Get(); } break; } } } return nullptr; }
/************************************************************************************** *Function Name: destroyPageFile * *Description: * destroy a txt file called fileName at "/Users/mac/Desktop/" *Parameters: * char *fileName: the fileName user want to open *Return: * RC_OK; *Author: * BO PENG *Hisory: * Date Name Content * ---------- ------------------------------ --------------- * 1/28/2016 BO PENG<*****@*****.**> first create using joinString to rewrite * 1/30/2016 BO PENG<*****@*****.**> add header comments * 1/30/2016 BO PENG<*****@*****.**> run on main(), and it worked **************************************************************************************/ RC destroyPageFile(char *fileName) { //extern RC destroyPageFile (char *fileName) if (fileName == NULL) { return RC_FILE_NOT_FOUND; } // join the file path, fileName and file type. // For example: // "/Users/mac/Desktop/" + "fileName" + ".txt" char *address = "/Users/mac/Desktop/"; char *firstHalf = joinString(address, fileName); char *houzhui = ".txt"; char *fullAddress = joinString(firstHalf, houzhui); //delete such file remove(fullAddress); return RC_OK; }
/************************************************************************************** *Function Name: openPageFile * *Description: * open a txt file called fileName at "/Users/mac/Desktop/" *Parameters: * char *fileName: the fileName user want to open * SM_FileHandle *fHandle: a strcture to save opened txt file's Info *Return: * RC_OK; *Author: * BO PENG *Hisory: * Date Name Content * ---------- ------------------------------ --------------- * 1/26/2016 BO PENG<*****@*****.**> first create * 1/26/2016 BO PENG<*****@*****.**> add comments * 1/27/2016 BO PENG<*****@*****.**> use joinString to rewrite * 1/29/2016 BO PENG<*****@*****.**> add show file content onto screen part * 1/30/2016 BO PENG<*****@*****.**> add header comments * 1/30/2016 BO PENG<*****@*****.**> run on main(), and it worked **************************************************************************************/ RC openPageFile(char *fileName, SM_FileHandle *fHandle) { //initial variable FILE *fwatch; FILE *fp; char ch; long fileSize; long lastPos = -1; // join the file path, fileName and file type. // For example: // "/Users/mac/Desktop/" + "fileName" + ".txt" char *address = "/Users/mac/Desktop/"; char *firstHalf = joinString(address, fileName); char *houzhui = ".txt"; char *fullAddress = joinString(firstHalf, houzhui); // fullAddress = "/Users/mac/Desktop/" + "fileName" + ".txt" // show the file on screen fwatch=fopen(fullAddress,"rt"); ch = fgetc(fwatch); //character of file while(ch!=EOF) { //end of file(EOF) putchar(ch); // show the file character by character ch=fgetc(fwatch); } fclose(fwatch); //collect file info: 1)fileName, 2)totalNumPages, 3)curPagePos, 4)mgmtInfo fp =fopen(fullAddress,"rt+"); if(fp ==NULL) { return RC_FILE_NOT_FOUND; } int Ban; Ban = fseek(fp, 0L, SEEK_END); if(Ban == -1) { //if failed return RC_UNESPECTED_ERROR; } // if rellocating pointer is success lastPos = ftell(fp); //locate the lastPosistion in the file fileSize = lastPos + 1; fHandle->fileName = fileName; fHandle->totalNumPages = (int) fileSize/PAGE_SIZE; fHandle->mgmtInfo = fp; fHandle ->curPagePos =0; return RC_OK; }
std::string MouseEvent::buttonName() const { std::vector<std::string> names; if (button_ & MOUSE_BUTTON_LEFT) names.push_back(buttonNames_[1]); if (button_ & MOUSE_BUTTON_MIDDLE) names.push_back(buttonNames_[2]); if (button_ & MOUSE_BUTTON_RIGHT) names.push_back(buttonNames_[3]); if (!names.empty()) { return joinString(names, "+"); } else { return buttonNames_[0]; } }
/************************************************************************************** *Function Name: createPageFile * *Description: * create a txt file into "/Users/mac/Desktop/" * Initial content is: first page is full of "\0" *Parameters: * char *fileName: the fileName user want to call * *Return: * RC_OK; *Author: * BO PENG *Hisory: * Date Name Content * ---------- ------------------------------ --------------- * 1/26/2016 BO PENG<*****@*****.**> first create * 1/26/2016 BO PENG<*****@*****.**> add comments * 1/27/2016 BO PENG<*****@*****.**> use joinString to rewrite * 1/30/2016 BO PENG<*****@*****.**> add header comments * 1/30/2016 BO PENG<*****@*****.**> run on main(), and it worked **************************************************************************************/ RC createPageFile(char *fileName) { if(fileName==NULL) { //when fileName is NULL return RC_FILE_NOT_FOUND; } // join the file path, fileName and file type. // For example: // "/Users/mac/Desktop/" + "fileName" + ".txt" char *address = "/Users/mac/Desktop/"; char *firstHalf = joinString(address, fileName); char *houzhui = ".txt"; char *fullAddress = joinString(firstHalf, houzhui); //initial the new file's first page with "\0" FILE *fp=fopen(fullAddress,"w"); //build a file and get file stream char str[PAGE_SIZE];//allocate a block space, which size is PAGE_SIZE bytes memset(str,'\0',PAGE_SIZE); // fill the array with '/0' fwrite(str, PAGE_SIZE, 1, fp); //put the block into the file fclose(fp); return RC_OK; }
void HelpWidget::showDocForClassName(std::string classIdentifier) { if (!helpEngine_) return; std::string className = joinString(splitString(classIdentifier, '.'), "_8"); QUrl url(QString::fromStdString("qthelp://org.inviwo/doc/docpage-" + className + ".html")); QUrl foundUrl = helpEngine_->findFile(url); if (foundUrl.isValid()) { helpBrowser_->setSource(foundUrl); } else { helpBrowser_->setText(QString("No documentation available")); } }
bool util::xmlCopyMatchingSubPropsIntoComposite(TxElement* node, const CompositeProperty& prop) { TxElement propitem("Property"); propitem.SetAttribute("type", prop.getClassIdentifier()); propitem.SetAttribute("identifier", prop.getIdentifier()); propitem.SetAttribute("displayName", prop.getDisplayName()); propitem.SetAttribute("key", prop.getIdentifier()); TxElement list("Properties"); propitem.InsertEndChild(list); node->InsertEndChild(propitem); std::vector<Property*> props = prop.getProperties(); bool res = false; for (auto& p : props) { bool match = false; ticpp::Iterator<ticpp::Element> child; for (child = child.begin(node); child != child.end(); child++) { std::string name; child->GetValue(&name); std::string type = child->GetAttributeOrDefault("type", ""); std::string id = child->GetAttributeOrDefault("identifier", ""); if (p->getIdentifier() == id && (p->getClassIdentifier() == type || p->getClassIdentifier() == splitString(type, '.').back())) { LogInfoCustom("VersionConverter", " Match for sub property: " + joinString(p->getPath(), ".") + " found in type: " << type << " id: " << id); list.InsertEndChild(*(child.Get())); match = true; } } res = res && match; } return res; }