virtual void Execute( const vector<string> &args ) { if ( args.size() != 1 ) { cerr << GetUsage() << "\n"; } exit( 0 ); }
int DumpPacketCommand::Execute() { if (remaining().empty()) { cout << GetUsage() << GetHelp() << endl; return 2; } const string filename(remaining().front()); return dump_file(filename); }
nsresult nsDOMStorageMemoryDB::SetKey(DOMStorageImpl* aStorage, const nsAString& aKey, const nsAString& aValue, PRBool aSecure, PRInt32 aQuota, PRBool aExcludeOfflineFromUsage, PRInt32 *aNewUsage) { nsresult rv; nsInMemoryStorage* storage; rv = GetItemsTable(aStorage, &storage); NS_ENSURE_SUCCESS(rv, rv); PRInt32 usage = 0; if (!aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage).IsEmpty()) { rv = GetUsage(aStorage, aExcludeOfflineFromUsage, &usage); NS_ENSURE_SUCCESS(rv, rv); } usage += aKey.Length() + aValue.Length(); nsInMemoryItem* item; if (!storage->mTable.Get(aKey, &item)) { if (usage > aQuota) { return NS_ERROR_DOM_QUOTA_REACHED; } item = new nsInMemoryItem(); if (!item) return NS_ERROR_OUT_OF_MEMORY; storage->mTable.Put(aKey, item); storage->mUsageDelta += aKey.Length(); } else { if (!aSecure && item->mSecure) return NS_ERROR_DOM_SECURITY_ERR; usage -= aKey.Length() + item->mValue.Length(); if (usage > aQuota) { return NS_ERROR_DOM_QUOTA_REACHED; } } storage->mUsageDelta += aValue.Length() - item->mValue.Length(); item->mValue = aValue; item->mSecure = aSecure; *aNewUsage = usage; MarkScopeDirty(aStorage); return NS_OK; }
virtual void Execute( const vector<string> &args ) { if ( args.size() == 1 ) { m_pokerClient->printAllTourID(); return; } cerr << GetUsage() << "\n"; }
void IndexBuffer::BufferData(const size_t size, void *data) { PROFILE_SCOPED() assert(m_mapMode == BUFFER_MAP_NONE); //must not be currently mapped if (GetUsage() == BUFFER_USAGE_DYNAMIC) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)size, (GLvoid*)data, GL_DYNAMIC_DRAW); } }
virtual void Execute( const vector<string> &args ) { if ( args.size() == 2 ) { m_pokerClient->selectTour(atoi(args[1].c_str())); cout << "Tour[" << args[1] << "] has been selected." << endl; return; } cerr << GetUsage() << "\n"; }
virtual void Execute( const vector<string> &args ) { if ( args.size() == 2 ) { auto tourID = atoi(args[1].c_str()); m_pokerClient->printTourInfo(tourID); return; } cerr << GetUsage() << "\n"; }
virtual void Execute( const vector<string> &args ) { if ( args.size() == 3 ) { auto tourID = m_pokerClient->createTour(atoi(args[1].c_str()),atoi(args[2].c_str())); cout << "Tour[" << tourID << "] has been created." << endl; return; } cerr << GetUsage() << "\n"; }
GLBuffer::GLBuffer(BufferDescription const& description, void const* source) : Buffer(description) { GLenum target = ResourceTypeToGLTarget(GetType()); GLenum glusage = ResourceUsageToGLUsage(GetUsage()); JOH_ASSERT(source != 0, "source data is null"); JOH_ASSERTF(target != 0, "Error calculating OpenGL target for ResourceType: %i", GetType()); JOH_ASSERTF(glusage != 0, "Error calculating OpenGL usage for ResourceUsage: %i", GetUsage()); glGenBuffers(1, &handle_); glBindBuffer(target, handle_); glBufferData(target, GetSize(), source, glusage); }
void Moose::Graphics::CVertexDescriptor::UpdateCache( ) { if ( IsCached() ) { glBindBuffer(GL_ARRAY_BUFFER, GetCache()); glBufferData( GL_ARRAY_BUFFER, GetByteSize(), GetPointer<float>(), ( (GetUsage() == Moose::Core::CACHE_DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW )); glBindBuffer(GL_ARRAY_BUFFER, 0); SetState(Moose::Core::CACHE_UP2DATE); } }
int SubReqCommand::Execute() { Networks networks(*config()->config()); if (!networks.IsInitialized()) { LOG(ERROR) << "Unable to load networks."; return 1; } wwiv::net::NetworkCommandLine net_cmdline(config()->bbsdir(), arg("net").as_int()); if (!net_cmdline.IsInitialized()) { return 1; } auto r = this->remaining(); if (r.size() < 3) { cout << GetUsage(); return 2; } auto net = net_cmdline.network(); string packet_filename = wwiv::net::create_pend(net.dir, false, 'r'); uint16_t main_type = main_type_sub_add_req; auto add_drop = upcase(r.at(0).front()); if (add_drop != 'A') { main_type = main_type_sub_drop_req; } net_header_rec nh = {}; auto host = StringToUnsignedShort(r.at(2)); nh.tosys = static_cast<uint16_t>(host); nh.touser = 1; nh.fromsys = net.sysnum; nh.fromuser = 1; nh.main_type = main_type_sub_add_req; // always use 0 since we use the stype nh.minor_type = 0; nh.list_len = 0; nh.daten = static_cast<uint32_t>(time(nullptr)); nh.method = 0; // This is an alphanumeric sub type. auto subtype = r.at(1); nh.length = subtype.size() + 1; string text = subtype; StringUpperCase(&text); text.push_back('\0'); wwiv::net::Packet packet(nh, {}, text); bool ok = wwiv::net::write_packet(packet_filename, net, packet); if (!ok) { LOG(ERROR) << "Error writing packet: " << packet_filename; return 1; } LOG(INFO) << "Wrote Packet: " << packet_filename; return 0; }
ERMsg COGRBaseOption::ParseOption(int argc, char* argv[]) { ERMsg msg; // Must process GDAL_SKIP before GDALAllRegister(), but we can't call // GDALGeneralCmdLineProcessor before it needs the drivers to be registered // for the --format or --formats options for (int i = 1; i < argc; i++) { if (IsEqual(argv[i], "--config") && i + 2 < argc && IsEqual(argv[i + 1], "GDAL_SKIP")) { CPLSetConfigOption(argv[i + 1], argv[i + 2]); i += 2; } } // -------------------------------------------------------------------- // Register standard GDAL drivers, and process generic GDAL // command options. // -------------------------------------------------------------------- OGRRegisterAll(); argc = OGRGeneralCmdLineProcessor(argc, &argv, 0); if (argc < 1) exit(-argc); // -------------------------------------------------------------------- // Parse arguments. // -------------------------------------------------------------------- for (int i = 1; i < argc; i++) { msg += ProcessOption(i, argc, argv); } if (m_bVersion) { string error = Format("%s was compiled against GDAL %s and is running against GDAL %s\n", argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME")); msg.ajoute(error); //return msg; } if (m_bNeedHelp) { msg.ajoute(GetUsage()); msg.ajoute(GetHelp()); //return msg; } return msg; }
virtual void Execute( const vector<string> &args ) { if ( args.size() == 1 || args.size() == 2 ) { if ( args.size() == 1 ) { cout << "Connecting to localhost:3567\n" << endl; m_pokerClient->connect( "localhost" , "3567" ); } else { cout << "Connecting to server: " << args[1] << endl; m_pokerClient->connect( args[1], "3567" ); } return; } cerr << GetUsage() << "\n"; }
//! print the usage to the message sink void ConsoleCommand::PrintUsage(MessageSink* pOutput) { std::string wstr = "Command : "; wstr += GetName(); pOutput->AppendMessage( wstr ); wstr = "usage : "; pOutput->AppendMessage( wstr ); wstr = " "; wstr += GetUsage(); pOutput->AppendMessage( wstr ); }
matrix4x4f* InstanceBuffer::Map(BufferMapMode mode) { assert(mode != BUFFER_MAP_NONE); //makes no sense assert(m_mapMode == BUFFER_MAP_NONE); //must not be currently mapped m_mapMode = mode; if (GetUsage() == BUFFER_USAGE_STATIC) { glBindBuffer(GL_ARRAY_BUFFER, m_buffer); if (mode == BUFFER_MAP_READ) return reinterpret_cast<matrix4x4f*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY)); else if (mode == BUFFER_MAP_WRITE) return reinterpret_cast<matrix4x4f*>(glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY)); } return m_data.get(); }
void VertexBuffer::CloneTo(VertexBuffer &vb) const { if (GLEW_ARB_vertex_buffer_object) { BYTE *data = (BYTE *)Map(GL_READ_ONLY); if (data) { vb.SetData(GetSize(), data, GetUsage()); Unmap(); } } else { delete [] vb.ptr->data; vb.ptr->size = ptr->size; vb.ptr->data = new BYTE[ptr->size]; memcpy(vb.ptr->data, ptr->data, ptr->size); } }
// ------------------------------------------------------------ InstanceBuffer::InstanceBuffer(Uint32 size, BufferUsage hint) : Graphics::InstanceBuffer(size, hint) { assert(size > 0); const GLenum usage = (hint == BUFFER_USAGE_STATIC) ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW; glGenBuffers(1, &m_buffer); glBindBuffer(GL_ARRAY_BUFFER, m_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(matrix4x4f) * m_size, 0, usage); glBindBuffer(GL_ARRAY_BUFFER, 0); if (GetUsage() != BUFFER_USAGE_STATIC) { m_data.reset(new matrix4x4f[size]); memset(m_data.get(), 0, sizeof(matrix4x4f) * size); } }
void InstanceBuffer::Unmap() { assert(m_mapMode != BUFFER_MAP_NONE); //not currently mapped if (GetUsage() == BUFFER_USAGE_STATIC) { glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); } else { if (m_mapMode == BUFFER_MAP_WRITE) { glBindBuffer(GL_ARRAY_BUFFER, m_buffer); glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(matrix4x4f) * m_size, m_data.get()); glBindBuffer(GL_ARRAY_BUFFER, 0); } } m_mapMode = BUFFER_MAP_NONE; }
void IndexBuffer::Unmap() { assert(m_mapMode != BUFFER_MAP_NONE); //not currently mapped if (GetUsage() == BUFFER_USAGE_STATIC) { glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } else { if (m_mapMode == BUFFER_MAP_WRITE) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeof(Uint32) * m_size, m_data); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } } m_mapMode = BUFFER_MAP_NONE; }
// ------------------------------------------------------------ IndexBuffer::IndexBuffer(Uint32 size, BufferUsage hint) : Graphics::IndexBuffer(size, hint) { assert(size > 0); const GLenum usage = (hint == BUFFER_USAGE_STATIC) ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW; glGenBuffers(1, &m_buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Uint32) * m_size, 0, usage); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); if (GetUsage() != BUFFER_USAGE_STATIC) { m_data = new Uint32[size]; memset(m_data, 0, sizeof(Uint32) * size); } else m_data = nullptr; }
void GLBuffer::SetData(void* source, uint32_t size, uint32_t offset) { GLenum target = ResourceTypeToGLTarget(GetType()); GLenum glusage = ResourceUsageToGLUsage(GetUsage()); JOH_ASSERT(source != 0, "source data is null"); JOH_ASSERTF(target != 0, "Error calculating OpenGL target for ResourceType: %i", GetType()); JOH_ASSERTF(glusage != 0, "Error calculating OpenGL usage for ResourceUsage: %i", GetUsage()); glBindBuffer(target, handle_); if (offset == 0) { glBufferData(target, size, source, glusage); uint32_t elementSize = GetElementSize(); count_ = size / elementSize; } else { JOH_ASSERT(offset + size <= GetSize(), "offset and size together extends beyond the buffer's allocated memory"); glBufferSubData(target, offset, size, source); } }
// ------------------------------------------------------------ IndexBuffer::IndexBuffer(Uint32 size, BufferUsage hint) : Graphics::IndexBuffer(size, hint) { assert(size > 0); const GLenum usage = (hint == BUFFER_USAGE_STATIC) ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW; glGenBuffers(1, &m_buffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); m_data = new Uint32[size]; memset(m_data, 0, sizeof(Uint32) * size); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Uint32) * m_size, m_data, usage); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); //Don't keep client data around for static buffers if (GetUsage() == BUFFER_USAGE_STATIC) { delete[] m_data; m_data = nullptr; } }
//------------------------------------------------------------------------------------ void D3D11Texture::GenMipMaps() { _AST(GetUsage() & eTextureUsage_AutoGenMips); g_pRenderSys->GetDeviceContext()->GenerateMips(m_pSRV); }
nsresult nsDOMStoragePersistentDB::SetKey(DOMStorageImpl* aStorage, const nsAString& aKey, const nsAString& aValue, PRBool aSecure, PRInt32 aQuota, PRBool aExcludeOfflineFromUsage, PRInt32 *aNewUsage) { nsresult rv; rv = EnsureLoadTemporaryTableForStorage(aStorage); NS_ENSURE_SUCCESS(rv, rv); PRInt32 usage = 0; if (!aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage).IsEmpty()) { rv = GetUsage(aStorage, aExcludeOfflineFromUsage, &usage); NS_ENSURE_SUCCESS(rv, rv); } aStorage->CacheKeysFromDB(); usage += aKey.Length() + aValue.Length(); nsAutoString previousValue; PRBool secure; rv = aStorage->GetCachedValue(aKey, previousValue, &secure); if (NS_SUCCEEDED(rv)) { if (!aSecure && secure) return NS_ERROR_DOM_SECURITY_ERR; usage -= aKey.Length() + previousValue.Length(); } if (usage > aQuota) { return NS_ERROR_DOM_QUOTA_REACHED; } rv = EnsureInsertTransaction(); NS_ENSURE_SUCCESS(rv, rv); mozStorageStatementScoper scopeinsert(mInsertKeyStatement); Binder binder(mInsertKeyStatement, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = binder->BindUTF8StringByName(NS_LITERAL_CSTRING("scope"), aStorage->GetScopeDBKey()); NS_ENSURE_SUCCESS(rv, rv); rv = binder->BindStringByName(NS_LITERAL_CSTRING("key"), aKey); NS_ENSURE_SUCCESS(rv, rv); rv = binder->BindStringByName(NS_LITERAL_CSTRING("value"), aValue); NS_ENSURE_SUCCESS(rv, rv); rv = binder->BindInt32ByName(NS_LITERAL_CSTRING("secure"), aSecure ? 1 : 0); NS_ENSURE_SUCCESS(rv, rv); rv = binder.Add(); NS_ENSURE_SUCCESS(rv, rv); rv = mInsertKeyStatement->Execute(); NS_ENSURE_SUCCESS(rv, rv); if (!aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage).IsEmpty()) { mCachedOwner = aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage); mCachedUsage = usage; } *aNewUsage = usage; return NS_OK; }
void Command::ShowUsage() const { std::cout << "Usage: " << GetUsage() << std::endl; }
nsresult nsDOMStorageDBWrapper::GetUsage(DOMStorageImpl* aStorage, bool aExcludeOfflineFromUsage, PRInt32 *aUsage) { IMPL_FORWARDER(GetUsage(aStorage, aExcludeOfflineFromUsage, aUsage)); }
nsresult nsDOMStorageDBWrapper::GetUsage(DOMStorageImpl* aStorage, int32_t *aUsage) { IMPL_FORWARDER(GetUsage(aStorage, aUsage)); }
void BufferObject::BufferData(Usage usage, int size, const void *data) { Begin(); GL_CHECKED(glBufferData(_type, size, data, GetUsage(usage))); End(); }
helpWindow::helpWindow() { { int width = 28 * FL_NORMAL_SIZE; int height = 19 * BH; about = new paletteWindow (width, height, CTX::instance()->nonModalWindows ? true : false, "About Gmsh"); about->box(GMSH_WINDOW_BOX); Fl_Help_View *o = new Fl_Help_View(0, 0, width, height); o->textfont(FL_HELVETICA); o->textsize(FL_NORMAL_SIZE); o->box(FL_FLAT_BOX); std::ostringstream sstream; sstream << "<center><h3>Gmsh</h3><br>version " << GetGmshVersion() << "<p>Copyright (C) 1997-2015" << "<br>Christophe Geuzaine and Jean-Francois Remacle" << "<p><a href=\"http://geuz.org/gmsh/doc/CREDITS.txt\">Credits</a> " << "and <a href=\"http://geuz.org/gmsh/doc/LICENSE.txt\">licensing " << "information</a>" << "<p>Please send all questions and bug reports to the public mailing list " << "<a href=\"mailto:[email protected]\">[email protected]</a></center>" << "<ul>" << "<li><i>Build OS:</i> " << GetGmshBuildOS() << "<li><i>Build date:</i> " << GetGmshBuildDate() << "<li><i>Build host:</i> " << GetGmshBuildHost() << "<li><i>Build options:</i>" << GetGmshBuildOptions() << "<li><i>FLTK version:</i> " << FL_MAJOR_VERSION << "." << FL_MINOR_VERSION << "." << FL_PATCH_VERSION #if defined(HAVE_PETSC) << "<li><i>PETSc version:</i> " << PETSC_VERSION_MAJOR << "." << PETSC_VERSION_MINOR << "." << PETSC_VERSION_SUBMINOR #if defined(PETSC_USE_COMPLEX) << " (complex arithmetic)" #else << " (real arithmetic)" #endif #endif #if defined(HAVE_OCC) << "<li><i>OCC version:</i> " << OCC_VERSION_MAJOR << "." << OCC_VERSION_MINOR << "." << OCC_VERSION_MAINTENANCE #endif #if defined(HAVE_MED) << "<li><i>MED version:</i> " << MED_NUM_MAJEUR << "." << MED_NUM_MINEUR << "." << MED_NUM_RELEASE #endif << "<li><i>Packaged by:</i> " << GetGmshPackager() << "</ul>" << "<center>Visit <a href=\"http://geuz.org/gmsh/\">http://geuz.org/gmsh/</a> " << "for more information</center>"; o->value(sstream.str().c_str()); o->link(help_link); about->position(Fl::x() + Fl::w()/2 - width / 2, Fl::y() + Fl::h()/2 - height / 2); about->end(); } { int width = 40 * FL_NORMAL_SIZE; int height = 18 * BH; basic = new paletteWindow (width, height, CTX::instance()->nonModalWindows ? true : false, "Keyboard and Mouse Usage"); basic->box(GMSH_WINDOW_BOX); Fl_Help_View *o = new Fl_Help_View(0, 0, width, height); o->textfont(FL_HELVETICA); o->textsize(FL_NORMAL_SIZE - 1); o->box(FL_FLAT_BOX); std::string s; s += "<h3>Keyboard Shortcuts</h3>"; s += "<table border=1>"; { std::vector<std::pair<std::string, std::string> > s0 = GetShortcutsUsage(); for(unsigned int i = 0; i < s0.size(); i++) s += "<tr><td>" + s0[i].first + "</td><td>" + s0[i].second + "</td></tr>"; } s += "</table>"; s += "<h3>Mouse Actions</h3>"; s += "<table border=1>"; { std::vector<std::pair<std::string, std::string> > s0 = GetMouseUsage(); for(unsigned int i = 0; i < s0.size(); i++) s += "<tr><td>" + s0[i].first + "</td><td>" + s0[i].second + "</td></tr>"; } s += "</table>"; s += "For a 2 button mouse, Middle button = Shift+Left button.<p>"; s += "For a 1 button mouse, Middle button = Shift+Left button, " "Right button = Alt+Left button."; s += "<h3>Command Line Switches</h3>"; s += "<table border=1>"; { std::vector<std::pair<std::string, std::string> > s0 = GetUsage(); for(unsigned int i = 0; i < s0.size(); i++) if(s0[i].first.size() && s0[i].second.size()) s += "<tr><td>" + s0[i].first + "</td><td>" + s0[i].second + "</td></tr>"; else if(s0[i].first.size() && s0[i].second.empty()) s += "</table>" + s0[i].first + "<table border=1>"; } s += "</table>"; o->value(s.c_str()); basic->resizable(o); basic->position(Fl::x() + Fl::w()/2 - width / 2, Fl::y() + Fl::h()/2 - height / 2); basic->end(); } { int width = 40 * FL_NORMAL_SIZE; int height = 18 * BH; options = new paletteWindow (width, height, CTX::instance()->nonModalWindows ? true : false, "Current Options and Workspace"); options->box(GMSH_WINDOW_BOX); int BW = (width - 4 * WB) / 3; modified = new Fl_Check_Button (WB, WB, BW, BH, "Only show modified"); modified->type(FL_TOGGLE_BUTTON); modified->callback(help_options_cb); modified->tooltip("Show only values different from defaults"); showhelp = new Fl_Check_Button (2 * WB + BW, WB, BW, BH, "Show help"); showhelp->type(FL_TOGGLE_BUTTON); showhelp->callback(help_options_cb); showhelp->tooltip("Show help strings"); Fl_Group* o = new Fl_Group(3 * WB + 2 * BW, WB, BW, BH); o->tooltip("Filter values"); o->box(FL_DOWN_BOX); o->color(FL_BACKGROUND2_COLOR); search = new Fl_Input (3 * WB + 2 * BW + BH, WB + 2, BW - BH - 2, BH - 4, "@gmsh_search"); search->box(FL_FLAT_BOX); search->callback(help_options_cb); search->when(FL_WHEN_CHANGED); //search->take_focus(); cannot call this here - it triggers show() on Linux in fltk 1.3.3 o->resizable(search); o->end(); browser = new Fl_Browser(0, BH + 2 * WB, width, height - BH - 2 * WB); browser->box(GMSH_SIMPLE_TOP_BOX); browser->textfont(FL_SCREEN); browser->textsize(FL_NORMAL_SIZE - 2); browser->type(FL_MULTI_BROWSER); browser->callback(browser_cb); browser->tooltip("Double-click to edit value"); browser->scrollbar_size(std::max(10, FL_NORMAL_SIZE - 2)); // thinner scrollbars options->resizable(browser); options->position(Fl::x() + Fl::w()/2 - width / 2, Fl::y() + Fl::h()/2 - height / 2); options->size_range(width, height); options->end(); } }