コード例 #1
0
ファイル: Ioss_SideBlock.C プロジェクト: crtrott/Trilinos
int  Ioss::SideBlock::get_consistent_side_number() const
{
  if (consistentSideNumber == -1) {
    // It wasn't calculated during the metadata reading of the surfaces.
    // Determine it now...
    if (field_exists("element_side")) {
      int side = 0;
      if (get_database()->int_byte_size_api() == 8) {
	std::vector<int64_t> element_side;
	get_field_data("element_side", element_side);
	side = internal_consistent_side_number(element_side);
      } else {
	std::vector<int> element_side;
	get_field_data("element_side", element_side);
	side = internal_consistent_side_number(element_side);
      }

      int side_max = get_database()->util().global_minmax(side, Ioss::ParallelUtils::DO_MAX);
      if (side_max != 999)
	consistentSideNumber = side_max;
      else
	consistentSideNumber = 0;
    } else {
      consistentSideNumber = 0;
    }
  }
  return consistentSideNumber;
}
コード例 #2
0
ファイル: handler.hpp プロジェクト: mrmoss/lonestar
inline bool handle_read(mg_connection* connection,const bool authenticated,const std::string& request,
	const std::string& query)
{
	std::string comma_list=get_query(connection,"read");

	if(comma_list.size()>0)
	{
		auto& database=get_database(connection);
		std::cout<<"\tReading \""<<comma_list<<"\"..."<<std::flush;

		if((database.permissions&P_READ)!=0||(authenticated&&database.allow_authentication()))
		{
			mg_send(connection,database.read(comma_list),"application/json");
			std::cout<<"done."<<std::endl;
		}
		else
		{
			mg_send_status(connection,"401 UNAUTHORIZED");
			std::cout<<"denied."<<std::endl;
		}

		return true;
	}

	return false;
}
コード例 #3
0
ファイル: handler.hpp プロジェクト: mrmoss/lonestar
inline bool handle_write(mg_connection* connection,const bool authenticated,const std::string& request,
	const std::string& query,const std::string& post_data)
{
	std::string comma_list=get_query(connection,"write");

	if(comma_list.size()>0)
	{
		auto& database=get_database(connection);
		std::cout<<"\tWriting \""<<comma_list<<"\"..."<<std::flush;

		if((database.permissions&P_WRITE)!=0||(authenticated&&database.allow_authentication()))
		{
			if(!database.write(comma_list,post_data))
			{
				mg_send_status(connection,"400 BAD REQUEST");
				std::cout<<"malformed."<<std::endl;
			}
			else
			{
				std::cout<<"done."<<std::endl;
			}
		}
		else
		{
			mg_send_status(connection,"401 UNAUTHORIZED");
			std::cout<<"denied."<<std::endl;
		}

		return true;
	}

	return false;
}
コード例 #4
0
ファイル: query.cpp プロジェクト: respu/librusql
int main(int argc, char *argv[]) {
	auto db = get_database(argc, argv);
	test_init(8);
	try {
		db->execute("CREATE TABLE rusqltest (`value` INT(2) NOT NULL)");
		pass("could run CREATE TABLE");
	} catch(std::exception &e) {
		diag(e);
		fail("could run CREATE TABLE");
	}
	test_start_try(1);
	try {
		auto res = db->query("SHOW TABLES");
		test(contains(res, "rusqltest"), "rusqltest table created");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	test_start_try(1);
	try {
		// SELECT on empty database
		auto res = db->query("SELECT * FROM rusqltest");
		test(!res, "no result rows in empty table");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	test_start_try(3);
	try {
		db->execute("INSERT INTO rusqltest (`value`) VALUES (27)");
		auto res = db->query("SELECT * FROM rusqltest");
		test(res, "result row in empty table");
		test(res.get_uint64(0) == 27, "correct result row in empty table");
		test(res.get_uint64("value") == 27, "correct result row by name in empty table");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	try {
		db->execute("DROP TABLE rusqltest");
		pass("could run DROP TABLE");
	} catch(std::exception &e) {
		diag(e);
		fail("could run DROP TABLE");
	}
	test_start_try(1);
	try {
		auto res = db->query("SHOW TABLES");
		test(!contains(res, "rusqltest"), "rusqltest table dropped");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();
	return 0;
}
コード例 #5
0
ファイル: table.cpp プロジェクト: respu/quince
void
table_base::specify_index_impl(bool is_unique, vector<unique_ptr<const abstract_mapper_base>> &&mappers) {
    if (_is_open)  throw table_open_exception();

    const index_spec spec(
        transform(
            std::move(mappers),
            [this](unique_ptr<const abstract_mapper_base> &m)  { return &own(m); }
        ),
        is_unique
    );
    if (! get_database().supports_index(spec))  throw unsupported_exception();
    _index_specs.push_back(spec);
}
コード例 #6
0
ファイル: Ioss_SideBlock.C プロジェクト: crtrott/Trilinos
void Ioss::SideBlock::block_membership(std::vector<std::string> &block_members)
{
  // Simplest case.  If the surfaces are split by element block, then this will return non-null
  // and we are done.
  const Ioss::ElementBlock *eb = parent_element_block();
  if (eb != nullptr) {
    block_members.push_back(eb->name());
    return;
  }

  if (blockMembership.empty()) {
    get_database()->compute_block_membership(this, blockMembership);
  } 
  block_members = blockMembership;
}
コード例 #7
0
ファイル: SyncEngineWrap.cpp プロジェクト: 3runo5ouza/rhodes
void CSyncEngineWrap::StartSyncEngine()
	{
		//lock_sync_mutex();
		if (!get_database())
		{
			char dbpath[KMaxFileName];
			sprintf(dbpath, "%sdb\\syncdb.sqlite", RhoGetRootPath());
			sqlite3 * iDatabase = 0;			
			sqlite3_open(dbpath, &iDatabase);

			rhoInitDatabase(iDatabase);
		}
		//unlock_sync_mutex();
	

	}
コード例 #8
0
ファイル: Ioss_SideSet.C プロジェクト: jbcarleton/seacas
int Ioss::SideSet::max_parametric_dimension() const
{
  int max_par_dim = 0;
  for (auto sideblock : sideBlocks) {
    int parametric_dim = sideblock->topology()->parametric_dimension();
    if (parametric_dim > max_par_dim) {
      max_par_dim = parametric_dim;
    }
  }
  if (max_par_dim == 0) {
    // If the sideset is empty, return the maximum that the parametric dimension
    // could be...
    // Faces for 3D model; Edges for 2D model
    const Ioss::Region *reg = get_database()->get_region();
    max_par_dim             = reg->get_property("spatial_dimension").get_int() - 1;
  }
  return max_par_dim;
}
コード例 #9
0
ファイル: signedness.cpp プロジェクト: Wassasin/librusql
int main(int argc, char *argv[]) {
	auto db = get_database(argc, argv);
	test_init(4);

	const  int16_t negative_int = -16000;
	const uint16_t high_int     = 34000;

	db->execute("CREATE TABLE rusqltest (`value` SMALLINT(3) NOT NULL)");
	test_start_try(2);
	try {
		db->execute("INSERT INTO rusqltest VALUES (?)", negative_int);
		pass("store negative int");
		auto res = db->select_query("SELECT * FROM rusqltest");
		test(res.get<int16_t>(0) == negative_int, "retrieve negative int");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();
	db->execute("DROP TABLE rusqltest");

	db->execute("CREATE TABLE rusqltest (`value` SMALLINT(3) UNSIGNED NOT NULL)");
	test_start_try(2);
	try {
		db->execute("INSERT INTO rusqltest VALUES (?)", high_int);
		pass("store high int");
		auto res = db->select_query("SELECT * FROM rusqltest");
		diag(res.get_string(0));
		test(res.get<uint16_t>(0) == high_int, "retrieve high int");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();
	db->execute("DROP TABLE rusqltest");

	return 0;
}
コード例 #10
0
ファイル: named_bind.cpp プロジェクト: Wassasin/librusql
int main(int argc, char *argv[]) {
	auto db = get_database(argc, argv);
	test_init(23);

	// TODO: after named_bind() is added, throw if it is called without execute()
	// TODO: throw if get() was called without fetch()
	// TODO: throw if get() was called without bind_results() (or once it's added, named_bind())
	// TODO: throw if get() was called with a nonexistant field

	db->execute("CREATE TABLE rusqltest (`id` INT(10) NOT NULL, `value` VARCHAR(10) NOT NULL)");
	db->execute("INSERT INTO rusqltest VALUES (?, ?), (?, ?), (?, ?)", 5, "a", 6, "b", 7, "c");

	test_start_try(10);
	try {
		auto statement = db->execute("SELECT * FROM rusqltest");

		statement.bind_all_self();

		test(statement.fetch(), "first result");
		test(statement.get<int>("id") == 5, "first result int");
		test(statement.get<std::string>("value") == "a", "first result string");
		test(statement.fetch(), "second result");
		test(statement.get<int>("id") == 6, "second result int");
		test(statement.get<std::string>("value") == "b", "second result string");
		test(statement.fetch(), "third result");
		test(statement.get<std::string>("value") == "c", "third result string");
		test(statement.get<int>("id") == 7, "third result int");
		test(!statement.fetch(), "end of results");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	// test NULL columns
	db->execute("DROP TABLE rusqltest");
	db->execute("CREATE TABLE rusqltest (`id` INT(10) NOT NULL, `value` VARCHAR(10) NULL)");
	db->execute("INSERT INTO rusqltest VALUES (?, ?), (?, NULL), (?, NULL)", 5, "a", 6, 7);

	test_start_try(13);
	try {
		auto statement = db->execute("SELECT * FROM rusqltest");

		statement.bind_all_self();

		test(statement.fetch(), "first result");
		test(statement.get<int>("id") == 5, "first result int");
		test(statement.get<std::string>("value") == "a", "first result string");
		boost::optional<std::string> placeholder;
		placeholder = statement.get<decltype(placeholder)>("value");
		test(placeholder, "first result string is set");
		test(*placeholder == "a", "first result string is correct");

		test(statement.fetch(), "second result");
		test(statement.get<int>("id") == 6, "second result int");
		placeholder = statement.get<decltype(placeholder)>("value");
		test(!placeholder, "second result string is not set");

		bool threw = false;
		try {
			statement.get<std::string>("value");
		} catch(std::exception &e) {
			threw = true;
		}
		test(threw, "get<string> doesn't return");

		test(statement.fetch(), "third result");
		placeholder = statement.get<decltype(placeholder)>("value");
		test(!placeholder, "third result string is not set");
		test(statement.get<int>("id") == 7, "third result int");
		test(!statement.fetch(), "end of results");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	return 0;
}
コード例 #11
0
int64_t Ioss::FaceBlock::internal_get_field_data(const Ioss::Field& field,
				      void *data, size_t data_size) const
{
  return get_database()->get_field(this, field, data, data_size);
}
コード例 #12
0
ファイル: Ioss_ElementSet.C プロジェクト: 00liujj/trilinos
int64_t Ioss::ElementSet::internal_put_field_data(const Ioss::Field& field,
				      void *data, size_t data_size) const
{
  return get_database()->put_field(this, field, data, data_size);
}
コード例 #13
0
 void ElementBlock::get_block_adjacencies(std::vector<std::string> &block_adjacency) const
 {
   get_database()->get_block_adjacencies(this, block_adjacency);
 }
コード例 #14
0
ファイル: handler.hpp プロジェクト: mrmoss/lonestar
inline void handle_nonce(mg_connection* connection)
{
	auto& database=get_database(connection);
	mg_send(connection,std::to_string(database.get_nonce()),"text/plain");
	std::cout<<"\tSending nonce...done."<<std::endl;
}
コード例 #15
0
ファイル: threads.cpp プロジェクト: Wassasin/librusql
int main(int argc, char *argv[]) {
	auto db = get_database(argc, argv);
	const int NUM_THREADS = 50;

	test_init(7 + NUM_THREADS);
	db->execute("CREATE TABLE rusqltest (`value` INT(2) NOT NULL)");
	db->execute("INSERT INTO rusqltest VALUES (20)");

	{
		auto statement = db->prepare("SELECT value FROM rusqltest");

		statement.execute();

		boost::thread thread([&db]() {
			auto thread_handle = db->get_thread_handle();
			db->execute("UPDATE rusqltest SET value=30");
		});
		thread.join();

		uint64_t value = 10;
		statement.bind_results(value);
		test(statement.fetch(), "one result");
		test(value == 20, "value was correct (" + std::to_string(value) + ")");
		test(!statement.fetch(), "exactly one result");

		statement.execute();
		statement.bind_results(value);
		test(statement.fetch(), "one result");
		test(value == 30, "value was correct (" + std::to_string(value) + ")");
		test(!statement.fetch(), "exactly one result");
	}

	db->execute("DELETE FROM rusqltest");
	db->execute("INSERT INTO rusqltest VALUES (0)");

	// Test simultaneous use of the database
	std::vector<std::shared_ptr<boost::thread>> threads;
	boost::mutex output_mutex;
	for(int i = 0; i < NUM_THREADS; ++i) {
		threads.emplace_back(std::make_shared<boost::thread>([i, &db, &output_mutex]() {
			auto thread_handle = db->get_thread_handle();
			try {
				for(int j = 0; j < 1000; ++j) {
					std::string iteration = std::to_string(i) + "," + std::to_string(j);
					{
						auto statement = db->prepare("SELECT value FROM rusqltest");
						statement.execute();
						uint64_t value;
						statement.bind_results(value);
						if(!statement.fetch()) {
							boost::mutex::scoped_lock lock(output_mutex);
							fail("First statement should succeed (iteration " + iteration + ")");
							return;
						}
						if(statement.fetch()) {
							boost::mutex::scoped_lock lock(output_mutex);
							fail("Second statement should fail (iteration " + iteration + ")");
							return;
						}
					}

					db->execute("UPDATE rusqltest SET value=value+1");
				}
				{
					boost::mutex::scoped_lock lock(output_mutex);
					pass("Thread " + std::to_string(i) + " succeeded");
				}
			} catch(...) {
				boost::mutex::scoped_lock lock(output_mutex);
				fail("Thread " + std::to_string(i) + " threw an exception");
			}
		}));
	}

	for(auto &thread : threads) {
		thread->join();
	}

	{
		auto statement = db->prepare("SELECT value FROM rusqltest");
		statement.execute();
		uint64_t result;
		statement.bind_results(result);
		statement.fetch();
		test(result == NUM_THREADS * 1000, "the right amount of increments was done");
	}

	db->execute("DROP TABLE rusqltest");
}
コード例 #16
0
ファイル: query.cpp プロジェクト: Wassasin/librusql
int main(int argc, char *argv[]) {
	auto db = get_database(argc, argv);
	test_init(14);
	try {
		db->execute("CREATE TABLE rusqltest (`value` INT(2) NOT NULL)");
		pass("could run CREATE TABLE");
	} catch(std::exception &e) {
		diag(e);
		fail("could run CREATE TABLE");
	}
	test_start_try(1);
	try {
		auto res = db->select_query("SHOW TABLES");
		test(contains(res, "rusqltest"), "rusqltest table created");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	test_start_try(1);
	try {
		// SELECT on empty database
		auto res = db->select_query("SELECT * FROM rusqltest");
		test(!res, "no result rows in empty table");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	test_start_try(3);
	try {
		db->execute("INSERT INTO rusqltest (`value`) VALUES (27)");
		auto res = db->select_query("SELECT * FROM rusqltest");
		test(res, "result row in empty table");
		test(res.get_uint64(0) == 27, "correct result row in empty table");
		test(res.get_uint64("value") == 27, "correct result row by name in empty table");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	try {
		db->execute("DROP TABLE rusqltest");
		pass("could run DROP TABLE");
	} catch(std::exception &e) {
		diag(e);
		fail("could run DROP TABLE");
	}
	test_start_try(1);
	try {
		auto res = db->select_query("SHOW TABLES");
		test(!contains(res, "rusqltest"), "rusqltest table dropped");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	try {
		db->query("DROP TABLE nonexistant");
		fail("DROP nonexistant table throws");
	} catch(std::exception &e) {
		pass("DROP nonexistant table throws");
	}

	try {
		db->select_query("SELECT 1");
		pass("Next query succeeds");
	} catch(std::exception &e) {
		fail("Next query succeeds");
	}

	try {
		db->select_query("CREATE DATABASE nonexistant2");
		fail("CREATE statement in select_query() throws");
	} catch(std::exception &e) {
		diag(e);
		pass("CREATE statement in select_query() throws");
	}

	try {
		db->execute("DROP DATABASE nonexistant2");
	} catch(...) {}

	try {
		db->query("SELECT 1");
		fail("SELECT query in query() throws");
	} catch(std::exception &e) {
		diag(e);
		pass("SELECT query in query() throws");
	}

	test_start_try(2);
	try {
		auto res = db->select_query("SELECT 234");
		test(res.get_uint64(0) == 234, "next SELECT statement after query() gives correct result");
		res.next();
		test(!res, "next SELECT statement after query() gives only one result");
	} catch(std::exception &e) {
		diag(e);
	}
	test_finish_try();

	return 0;
}
コード例 #17
0
  int64_t ElementBlock::internal_put_field_data(const Field& field,
						void *data, size_t data_size) const
  {
    return get_database()->put_field(this, field, data, data_size);
  }
コード例 #18
0
ファイル: handler.hpp プロジェクト: mrmoss/lonestar
inline int client_handler(mg_connection* connection,mg_event event)
{
	if(event==MG_AUTH)
		return MG_TRUE;

	if(event==MG_REQUEST)
	{
		std::string client(connection->remote_ip);
		for(int ii=0;ii<connection->num_headers&&client=="127.0.0.1";++ii)
			if(std::string(connection->http_headers[ii].name)=="X-Forwarded-For")
				client=connection->http_headers[ii].value;

		std::string method=(connection->request_method);
		std::string request(connection->uri);
		std::string post_data;
		std::string nonce_string=get_query(connection,"nonce");

		if(method=="POST")
			post_data=std::string(connection->content,connection->content_len);

		std::string query;
		if(connection->query_string!=nullptr)
			query=connection->query_string;

		auto& database=get_database(connection);
		bool authenticated=false;
		std::string auth=get_query(connection,"auth");
		if(auth.size()>0)
		{
				std::string query_no_auth=replace_all(query,"&auth="+auth,"");
				query_no_auth=replace_all(query_no_auth,"auth="+auth,"");
				authenticated=database.authenticate(query_no_auth+post_data,auth);
		}

		std::cout<<client;
		if(client==std::string(connection->remote_ip))
			std::cout<<" NOLOOKUP";
		else
			std::cout<<" LOOKUP  ";
		if(!authenticated)
			std::cout<<" NOAUTH";
		else
			std::cout<<" AUTH  ";
		std::cout<<" "<<method<<" "<<request<<"."<<std::endl;
		std::cout<<"\tQuery:  \""<<query<<"\""<<std::endl;

		if(method=="POST")
			std::cout<<"\tPost:  \""<<post_data<<"\""<<std::endl;

		if(nonce_string!=""&&nonce_string!="false")
		{
			handle_nonce(connection);
			return MG_TRUE;
		}

		bool wrote=false;

		if(method=="POST")
			wrote=handle_write(connection,authenticated,request,query,post_data);

		bool read=handle_read(connection,authenticated,request,query);

		if(wrote||read)
			return MG_TRUE;
	}

	return MG_FALSE;
}
コード例 #19
0
 AxisAlignedBoundingBox ElementBlock::get_bounding_box() const
 {
   return get_database()->get_bounding_box(this);
 }
コード例 #20
0
static Bool
init_x11( char * error_buf )
{
	/*XXX*/ /* Namely, support for -display host:0.0 etc. */
	XrmQuark common_quarks_list[20];  /*XXX change number of elements if necessary */
	XrmQuarkList ql = common_quarks_list;
	XGCValues gcv;
	char *common_quarks =
		"String."
		"Blinkinvisibletime.blinkinvisibletime."
		"Blinkvisibletime.blinkvisibletime."
		"Clicktimeframe.clicktimeframe."
		"Doubleclicktimeframe.doubleclicktimeframe."
		"Wheeldown.wheeldown."
		"Wheelup.wheelup."
		"Submenudelay.submenudelay."
		"Scrollfirst.scrollfirst."
		"Scrollnext.scrollnext";

	char * atom_names[AI_count] = {
		"RESOLUTION_X",
		"RESOLUTION_Y",
		"PIXEL_SIZE",
		"SPACING",
		"RELATIVE_WEIGHT",
		"FOUNDRY",
		"AVERAGE_WIDTH",
		"CHARSET_REGISTRY",
		"CHARSET_ENCODING",
		"CREATE_EVENT",
		"WM_DELETE_WINDOW",
		"WM_PROTOCOLS",
		"WM_TAKE_FOCUS",
		"_NET_WM_STATE",
		"_NET_WM_STATE_SKIP_TASKBAR",
		"_NET_WM_STATE_MAXIMIZED_VERT",
		"_NET_WM_STATE_MAXIMIZED_HORZ",
		"_NET_WM_NAME",
		"_NET_WM_ICON_NAME",
		"UTF8_STRING",
		"TARGETS",
		"INCR",
		"PIXEL",
		"FOREGROUND",
		"BACKGROUND",
		"_MOTIF_WM_HINTS",
		"_NET_WM_STATE_MODAL",
		"_NET_SUPPORTED",
		"_NET_WM_STATE_MAXIMIZED_HORIZ",
		"text/plain;charset=UTF-8",
		"_NET_WM_STATE_STAYS_ON_TOP",
		"_NET_CURRENT_DESKTOP",
		"_NET_WORKAREA",
		"_NET_WM_STATE_ABOVE"
	};
	char hostname_buf[256], *hostname = hostname_buf;

	guts. click_time_frame = 200;
	guts. double_click_time_frame = 200;
	guts. visible_timeout = 500;
	guts. invisible_timeout = 500;
	guts. insert = true;
	guts. last_time = CurrentTime;

	guts. ri_head = guts. ri_tail = 0;
	DISP = XOpenDisplay( do_display);
	
	if (!DISP) {
		char * disp = getenv("DISPLAY");
		snprintf( error_buf, 256, "Error: Can't open display '%s'", 
					do_display ? do_display : (disp ? disp : ""));
		free( do_display);
		do_display = nil;
		return false;
	}
	free( do_display);
	do_display = nil;
	XSetErrorHandler( x_error_handler);
	guts.main_error_handler = x_error_handler;
	(void)x_io_error_handler;
	XCHECKPOINT;
	guts.connection = ConnectionNumber( DISP);

	{
		struct sockaddr name;
		unsigned int l = sizeof( name);
		guts. local_connection = getsockname( guts.connection, &name, &l) >= 0 && l == 0;
	}
	
#ifdef HAVE_X11_EXTENSIONS_SHAPE_H
	if ( XShapeQueryExtension( DISP, &guts.shape_event, &guts.shape_error)) {
		guts. shape_extension = true;
	} else {
		guts. shape_extension = false;
	}
#else
	guts. shape_extension = false;
#endif
#ifdef USE_MITSHM
	if ( !do_no_shmem && XShmQueryExtension( DISP)) {
		guts. shared_image_extension = true;
		guts. shared_image_completion_event = XShmGetEventBase( DISP) + ShmCompletion;
	} else {
		guts. shared_image_extension = false;
		guts. shared_image_completion_event = -1;
	}
#else
	guts. shared_image_extension = false;
	guts. shared_image_completion_event = -1;
#endif
	guts. randr_extension = false;
#ifdef HAVE_X11_EXTENSIONS_XRANDR_H
	{
		int dummy;
		if ( XRRQueryExtension( DISP, &dummy, &dummy))
			guts. randr_extension = true;
	}	 
#endif
#ifdef HAVE_X11_EXTENSIONS_XRENDER_H
	{
		int dummy;
		if ( XRenderQueryExtension( DISP, &dummy, &dummy))
			guts. render_extension = true;
	}	 
#endif
#ifdef HAVE_X11_EXTENSIONS_XCOMPOSITE_H
	{
		int dummy;
		if (XQueryExtension(DISP, COMPOSITE_NAME, &guts.composite_opcode, &dummy, &dummy))
			guts. composite_extension = true;
	}	 
#endif
	XrmInitialize();
	guts.db = get_database();
	XrmStringToQuarkList( common_quarks, common_quarks_list);
	guts.qString = *ql++;
	guts.qBlinkinvisibletime = *ql++;
	guts.qblinkinvisibletime = *ql++;
	guts.qBlinkvisibletime = *ql++;
	guts.qblinkvisibletime = *ql++;
	guts.qClicktimeframe = *ql++;
	guts.qclicktimeframe = *ql++;
	guts.qDoubleclicktimeframe = *ql++;
	guts.qdoubleclicktimeframe = *ql++;
	guts.qWheeldown = *ql++;
	guts.qwheeldown = *ql++;
	guts.qWheelup = *ql++;
	guts.qwheelup = *ql++;
	guts.qSubmenudelay = *ql++;
	guts.qsubmenudelay = *ql++;
	guts.qScrollfirst = *ql++;
	guts.qscrollfirst = *ql++;
	guts.qScrollnext = *ql++;
	guts.qscrollnext = *ql++;

	guts. mouse_buttons = XGetPointerMapping( DISP, guts. buttons_map, 256);
	XCHECKPOINT;

	guts. limits. request_length = XMaxRequestSize( DISP);
	guts. limits. XDrawLines = guts. limits. request_length - 3;
	guts. limits. XFillPolygon = guts. limits. request_length - 4;
	guts. limits. XDrawSegments = (guts. limits. request_length - 3) / 2;
	guts. limits. XDrawRectangles = (guts. limits. request_length - 3) / 2;
	guts. limits. XFillRectangles = (guts. limits. request_length - 3) / 2;
	guts. limits. XFillArcs =
		guts. limits. XDrawArcs = (guts. limits. request_length - 3) / 3;
	XCHECKPOINT;
	SCREEN = DefaultScreen( DISP);

	/* XXX - return code? */
	guts. root = RootWindow( DISP, SCREEN);
	guts. displaySize. x = DisplayWidth( DISP, SCREEN);
	guts. displaySize. y = DisplayHeight( DISP, SCREEN);
	XQueryBestCursor( DISP, guts. root,
							guts. displaySize. x,     /* :-) */
							guts. displaySize. y,
							&guts. cursor_width,
							&guts. cursor_height);
	XCHECKPOINT;
	
	TAILQ_INIT( &guts.paintq);
	TAILQ_INIT( &guts.peventq);
	TAILQ_INIT( &guts.bitmap_gc_pool);
	TAILQ_INIT( &guts.screen_gc_pool);
	TAILQ_INIT( &guts.argb_gc_pool);

	guts. currentFocusTime = CurrentTime;
	guts. windows = hash_create();
	guts. menu_windows = hash_create();
	guts. ximages = hash_create();
	gcv. graphics_exposures = false;
	guts. menugc = XCreateGC( DISP, guts. root, GCGraphicsExposures, &gcv);
	guts. resolution. x = 25.4 * guts. displaySize. x / DisplayWidthMM( DISP, SCREEN) + .5;
	guts. resolution. y = 25.4 * DisplayHeight( DISP, SCREEN) / DisplayHeightMM( DISP, SCREEN) + .5;
	guts. depth = DefaultDepth( DISP, SCREEN);
	guts. idepth = get_idepth();
	if ( guts.depth == 1) guts. qdepth = 1; else
	if ( guts.depth <= 4) guts. qdepth = 4; else
	if ( guts.depth <= 8) guts. qdepth = 8; else
		guts. qdepth = 24;
	guts. byte_order = ImageByteOrder( DISP);
	guts. bit_order = BitmapBitOrder( DISP);
	if ( BYTEORDER == LSB32 || BYTEORDER == LSB64)
		guts. machine_byte_order = LSBFirst;
	else if ( BYTEORDER == MSB32 || BYTEORDER == MSB64)
		guts. machine_byte_order = MSBFirst;
	else {
		sprintf( error_buf, "UAA_001: weird machine byte order: %08x", BYTEORDER);
		return false;
	}  

	XInternAtoms( DISP, atom_names, AI_count, 0, guts. atoms);

	guts. null_pointer = nilHandle;
	guts. pointer_invisible_count = 0;
	guts. files = plist_create( 16, 16);
	prima_rebuild_watchers();
	guts. wm_event_timeout = 100;
	guts. menu_timeout = 200;
	guts. scroll_first = 200;
	guts. scroll_next = 50;
	apc_timer_create( CURSOR_TIMER);
	apc_timer_set_timeout(CURSOR_TIMER, 2);
	apc_timer_create( MENU_TIMER);
	apc_timer_set_timeout( MENU_TIMER,  guts. menu_timeout);
	apc_timer_create( MENU_UNFOCUS_TIMER);
	apc_timer_set_timeout( MENU_UNFOCUS_TIMER, 50);
	if ( !prima_init_clipboard_subsystem( error_buf)) return false;
	if ( !prima_init_color_subsystem( error_buf)) return false;
	if ( !prima_init_font_subsystem( error_buf)) return false;
#ifdef WITH_GTK2
	if (!prima_gtk_init()) return false;
#endif
	bzero( &guts. cursor_gcv, sizeof( guts. cursor_gcv));
	guts. cursor_gcv. cap_style = CapButt;
	guts. cursor_gcv. function = GXcopy;

	gethostname( hostname, 256);
	hostname[255] = '\0';
	XStringListToTextProperty((char **)&hostname, 1, &guts. hostname);
	
	guts. net_wm_maximization = prima_wm_net_state_read_maximization( guts. root, NET_SUPPORTED);

	if ( do_sync) XSynchronize( DISP, true);
	return true;
}
コード例 #21
0
ファイル: transaction.cpp プロジェクト: jamesg/hades
        hades::connection conn = hades::connection::in_memory_database();
        hades::devoid(
                "CREATE TABLE site ( "
                " site_id INTEGER PRIMARY KEY AUTOINCREMENT, "
                " name VARCHAR "
                " ) ",
                hades::empty_row(),
                conn
                );
        return conn;
    }
}

SCENARIO("hades::transaction") {
    GIVEN("a simple database") {
        hades::connection conn = get_database();
        WHEN("one transaction is run but not committed") {
            {
                hades::transaction tr(conn, "one_transaction_test");
                hades::devoid("INSERT INTO site(name) VALUES('test')", conn);
            }
            THEN("the transaction had no effect") {
                styx::list l = site::get_collection(conn);
                REQUIRE(l.size() == 0);
            }
        }
    }
    GIVEN("a simple database") {
        hades::connection conn = get_database();
        WHEN("one transaction is run and committed") {
            {
コード例 #22
0
ファイル: API_records.cpp プロジェクト: lesteriv/slite
//////////////////////////////////////////////////////////////////////////


/**********************************************************************************************/
static string g_empty_string;


//////////////////////////////////////////////////////////////////////////
// API table
//////////////////////////////////////////////////////////////////////////


/**********************************************************************************************/
DELETE( records/<db>/<table> )( cr_connection& conn )
{
	auto db = get_database( conn );
	if( !db )
		return;

	string query = string( "DELETE FROM \"" ) + conn.path_parameter( 1 ) + '"';

	string filter = conn.query_parameter( "filter" );
	if( filter.length() )
		query += " WHERE " + filter;

	db->query( conn, query, false );
}

/**********************************************************************************************/
DELETE( records/<db>/<table>/<rec_id> )( cr_connection& conn )
{