Пример #1
0
 Species(
     const std::string& name, const std::string& radius, const std::string& D)
     : name_(name)
 {
     set_attribute("radius", radius);
     set_attribute("D", D);
 }
Пример #2
0
Area::Area(const char *destination, int sx, int sy)
    : Object(Object::TypeArea, 0, 0),
      m_name(destination),
      m_type(TypeWarp),
      m_w(0), m_h(0),
      m_state(StateOpen)
{
    set_attribute("start_x", sx);
    set_attribute("start_y", sy);
}
Пример #3
0
Area::Area(Curse *curse)
    : Object(Object::TypeArea, curse->get_x(), curse->get_y()),
      m_name(curse->get_destination()),
      m_type(TypeCurse),
      m_w(curse->get_image_width()), m_h(curse->get_image_height()),
      m_data(curse->get_player()),
      m_state(StateOpen)
{
    set_attribute("start_x", curse->get_sx());
    set_attribute("start_y", curse->get_sy());
}
Пример #4
0
void
DataNode::set_attribute(const tstring &name, fixed value)
{
  TCHAR buf[100];
  _stprintf(buf, _T("%g"), (double)value);
  set_attribute(name, buf);
}
Пример #5
0
void
DataNode::set_attribute(const tstring &name, unsigned value)
{
  TCHAR buf[100];
  _stprintf(buf, _T("%d"), value);
  set_attribute(name, buf);
}
Пример #6
0
static struct line_info *
parse_git_color_option(struct line_info *info, char *value)
{
	const char *argv[SIZEOF_ARG];
	int argc = 0;
	bool first_color = TRUE;
	int i;

	if (!argv_from_string(argv, &argc, value))
		return NULL;

	info->fg = COLOR_DEFAULT;
	info->bg = COLOR_DEFAULT;
	info->attr = 0;

	for (i = 0; i < argc; i++) {
		int attr = 0;

		if (set_attribute(&attr, argv[i])) {
			info->attr |= attr;

		} else if (set_color(&attr, argv[i])) {
			if (first_color)
				info->fg = attr;
			else
				info->bg = attr;
			first_color = FALSE;
		}
	}
	return info;
}
Пример #7
0
environment decl_attributes::apply(environment env, io_state const & ios, name const & d, name const & ns) const {
    buffer<entry> entries;
    to_buffer(m_entries, entries);
    unsigned i = entries.size();
    while (i > 0) {
        --i;
        auto const & entry = entries[i];
        char const * attr = entry.m_attr.c_str();
        switch (get_attribute_kind(attr)) {
        case attribute_kind::Default:
            env = set_attribute(env, ios, attr, d, ns, m_persistent);
            break;
        case attribute_kind::Prioritized:
            if (m_prio)
                env = set_prio_attribute(env, ios, attr, d, *m_prio, ns, m_persistent);
            else
                env = set_prio_attribute(env, ios, attr, d, LEAN_DEFAULT_PRIORITY, ns, m_persistent);
            break;
        case attribute_kind::Parametric:
            env = set_param_attribute(env, ios, attr, d, head(entry.m_params), ns, m_persistent);
            break;
        case attribute_kind::OptParametric:
            if (entry.m_params)
                env = set_opt_param_attribute(env, ios, attr, d, optional<unsigned>(head(entry.m_params)), ns, m_persistent);
            else
                env = set_opt_param_attribute(env, ios, attr, d, optional<unsigned>(), ns, m_persistent);
            break;
        case attribute_kind::MultiParametric:
            env = set_params_attribute(env, ios, attr, d, entry.m_params, ns, m_persistent);
            break;
        }
    }
    return env;
}
Пример #8
0
void
DataNode::set_attribute(const tstring &name, bool &value)
{
  TCHAR buf[100];
  _stprintf(buf, _T("%d"), (int)value);
  set_attribute(name, buf);
}
Пример #9
0
static PyObject *
dict_setdefault(PyObject *_self, PyObject *args)
{
	attr_dir_object *self = (attr_dir_object*)_self;
	PyObject *key, *failobj;
	PyObject *val = NULL;
	kdump_ctx *ctx;
	kdump_attr_ref_t ref;
	kdump_attr_t attr;
	kdump_status status;

	failobj = Py_None;
	if (!PyArg_UnpackTuple(args, "setdefault", 1, 2, &key, &failobj))
		return NULL;

	if (get_attribute(self, key, &ref) <= 0)
		return NULL;

	ctx = self->kdumpfile->ctx;
	status = kdump_attr_ref_get(ctx, &ref, &attr);
	if (status == kdump_ok)
		val = attr_new(self->kdumpfile, &ref, &attr);
	else if (status == kdump_nodata)
		val = (set_attribute(self, &ref, failobj) == 0)
			? failobj
			: NULL;
	else {
		PyErr_SetString(exception_map(status), kdump_err_str(ctx));
		val = NULL;
	}
	kdump_attr_unref(ctx, &ref);

	Py_XINCREF(val);
	return val;
}
Пример #10
0
static void
parse_git_color_option(enum line_type type, char *value)
{
	struct line_info *info = get_line_info(type);
	const char *argv[SIZEOF_ARG];
	int argc = 0;
	bool first_color = TRUE;
	int i;

	if (!argv_from_string(argv, &argc, value))
		return;

	info->fg = COLOR_DEFAULT;
	info->bg = COLOR_DEFAULT;
	info->attr = 0;

	for (i = 0; i < argc; i++) {
		int attr = 0;

		if (set_attribute(&attr, argv[i])) {
			info->attr |= attr;

		} else if (set_color(&attr, argv[i])) {
			if (first_color)
				info->fg = attr;
			else
				info->bg = attr;
			first_color = FALSE;
		}
	}
}
Пример #11
0
void
Eclass::add_tokid(Tokid t)
{
	members.insert(t);
	t.set_ec(this);
	if (t.get_readonly()) {
		if (DP())
			cout << "readonly " << *this << "\n";
		set_attribute(is_readonly);
	}
	if (!Pdtoken::skipping()) {
		set_attribute(Project::get_current_projid());
		if (DP())
			cout << "Set_attribute for " << t << " to " << Project::get_current_projid() << "\n";
	}
}
Пример #12
0
/**
Редактировать атрибуты шрифта.
*/
void font::menu_Parametr ( void )
{
	int rez  = 0;
	int above = 0;
	int below = 0;
	int modes = 0;

	QString  attribute;

	do
	{
		print();
//  edit_menu::s_menu_font_parametr->run();
//  rez = edit_menu::s_menu_font_parametr->get_run_rez();

		switch ( rez )
		{

			case 0: //Above
				std_out << "Above (n>=1) <" << get_above () << "> =";
				std_out.flush();
				std_in >> above ;
				set_above ( above );
				break;

			case 1: //Below
				std_out << "Below (n>=1) <" << get_below() << "> =";
				std_out.flush();
				std_in >> below;
				set_below ( below );
				break;

			case 2: //Modes
				std_out << "Modes (0|2) <" << get_modes() << "> =";
				std_out.flush();
				std_in >> modes;
				set_modes ( modes );
				break;

			case 3: //Attribute
				std_out << "Attribute <" << get_attribute() << "> =";
				std_out.flush();
				attribute = std_in.readLine();
//    std_in >> attribute;
				set_attribute ( attribute );
				break;

			case 4: //Exit
				break;

			default:
				rez = 4;
				break;
		}
	}

	while ( rez >= 0 && rez < 4 );
}
void GeometryReference_t::writePart( const string& partname )
{
	int ipart;
	int ifam = parent().getID();
	int igeo = getID();
	int ier = cg_part_write( getFileID(), getBase().getID(), ifam, igeo, partname.c_str(), &ipart );
	check_error( "GeometryReference_t::writePart", "cg_part_write", ier );
	set_attribute( "NbGeoParts", ipart );
}
 static void set_attribute(Subgraph& g,
                           AttrState s, bool clear_attribute = true) {
   typedef Subgraph Graph;
   switch ( s ) {
   case GRAPH_GRAPH_A: 
     {
       boost::graph_property<Graph, boost::graph_graph_attribute_t>::type&
         gga = boost::get_property(g, boost::graph_graph_attribute);
       set_attribute(gga, attributes); 
     }
     break;
   case GRAPH_NODE_A: 
     {
       boost::graph_property<Graph, boost::graph_vertex_attribute_t>::type&
         gna = boost::get_property(g, boost::graph_vertex_attribute);
       set_attribute(gna, attributes); 
     }
     break;
   case GRAPH_EDGE_A: 
     {
       boost::graph_property<Graph, boost::graph_edge_attribute_t>::type&
         gea = boost::get_property(g, boost::graph_edge_attribute);
       set_attribute(gea, attributes); 
     }
     break;
   case NODE_A:
     {
       boost::property_map<Graph, boost::vertex_attribute_t>::type
         va = boost::get(boost::vertex_attribute, g);    //va[v]
       set_attribute(va[current_vertex], attributes);
     }
     break;
   case EDGE_A: 
     {
       boost::property_map<Graph, boost::edge_attribute_t>::type
         ea = boost::get(boost::edge_attribute, g);      //ea[e]
       set_attribute(ea[current_edge], attributes); 
     }
     break;
   }
   if ( clear_attribute )
     attributes.clear();
 }
Пример #15
0
    BOOL EShellTree::SetRoot(__in LPCWSTR pszRootPath = NULL)
    {
        DeleteAllChild();

        set_attribute("src",pszRootPath);

        attach(&CHLShellTree_instance);

        return TRUE;
    }
Пример #16
0
    BOOL EShellTree::SetRoot(__in int nClsID)
    {
        DeleteAllChild();

        wchar_t szBuf[10] = {0};
        swprintf_s(szBuf, 10, L"clsid:%d", nClsID);
        set_attribute("src", szBuf);

        attach(&CHLShellTree_instance);

        return TRUE;
    }
Пример #17
0
//*****************************************************************************
//
// This function resets the screen.
//
//*****************************************************************************
void
reset_screen(void)
{
    //
    // Select the text window.
    //
    select_text_window();

    //
    // Return the character rendering to normal.
    //
    set_attribute(NORMAL);
}
int test(struct IridiumContext * context) {
  setup(context);
  object a = ATOM("a");
  object attr = ATOM("attr");
  object val = ATOM("val");
  object internal_val = ATOM("internal_val");
  set_attribute(a, attr, PUBLIC, val);
  internal_set_attribute(a, attr, internal_val);

  assertEqual(get_attribute(a, attr, PUBLIC), val);
  assertEqual(internal_get_attribute(a, attr, object), internal_val);  
  return 0;
}
Пример #19
0
static int
attr_dir_ass_subscript(PyObject *_self, PyObject *key, PyObject *value)
{
	attr_dir_object *self = (attr_dir_object*)_self;
	kdump_attr_ref_t ref;
	int ret = -1;

	if (get_attribute(self, key, &ref) <= 0)
		return ret;

	ret = set_attribute(self, &ref, value);
	kdump_attr_unref(self->kdumpfile->ctx, &ref);
	return ret;
}
Пример #20
0
XMLSettings XMLSettingsMap::get(const std::string &key)
{
    for (auto cur = node->first_child(); cur; cur = cur->next_sibling())
    {
        if (!cur->is_element())
            continue;

        if (cur->attribute("key") == key)
            return XMLSettings(document, cur);
    }

    auto cur = node->owner_document()->create_element("item");
    cur->set_attribute("key", key);
    node->append_child(cur);
    return XMLSettings(document, cur);
}
Пример #21
0
Файл: options.c Проект: zhez/tig
/* Wants: object fgcolor bgcolor [attribute] */
static enum status_code
option_color_command(int argc, const char *argv[])
{
	struct line_rule rule = {};
	const char *prefix = NULL;
	struct line_info *info;
	enum status_code code;

	if (argc < 3)
		return ERROR_WRONG_NUMBER_OF_ARGUMENTS;

	code = parse_color_name(argv[0], &rule, &prefix);
	if (code != SUCCESS)
		return code;

	info = add_line_rule(prefix, &rule);
	if (!info) {
		static const struct enum_map_entry obsolete[] = {
			ENUM_MAP_ENTRY("main-delim",	LINE_DELIMITER),
			ENUM_MAP_ENTRY("main-date",	LINE_DATE),
			ENUM_MAP_ENTRY("main-author",	LINE_AUTHOR),
			ENUM_MAP_ENTRY("blame-id",	LINE_ID),
		};
		int index;

		if (!map_enum(&index, obsolete, argv[0]))
			return ERROR_UNKNOWN_COLOR_NAME;
		info = get_line_info(NULL, index);
	}

	if (!set_color(&info->fg, argv[1]) ||
	    !set_color(&info->bg, argv[2]))
		return ERROR_UNKNOWN_COLOR;

	info->attr = 0;
	while (argc-- > 3) {
		int attr;

		if (!set_attribute(&attr, argv[argc]))
			return ERROR_UNKNOWN_ATTRIBUTE;
		info->attr |= attr;
	}

	return SUCCESS;
}
Пример #22
0
/* Wants: object fgcolor bgcolor [attribute] */
static enum status_code
option_color_command(int argc, const char *argv[])
{
	struct line_info *info;

	if (argc < 3)
		return ERROR_WRONG_NUMBER_OF_ARGUMENTS;

	if (*argv[0] == '"' || *argv[0] == '\'') {
		info = add_custom_color(argv[0]);
	} else {
		info = find_line_info(argv[0], strlen(argv[0]), FALSE);
	}
	if (!info) {
		static const struct enum_map_entry obsolete[] = {
			ENUM_MAP_ENTRY("main-delim",	LINE_DELIMITER),
			ENUM_MAP_ENTRY("main-date",	LINE_DATE),
			ENUM_MAP_ENTRY("main-author",	LINE_AUTHOR),
			ENUM_MAP_ENTRY("blame-id",	LINE_ID),
		};
		int index;

		if (!map_enum(&index, obsolete, argv[0]))
			return ERROR_UNKNOWN_COLOR_NAME;
		info = get_line_info(index);
	}

	if (!set_color(&info->fg, argv[1]) ||
	    !set_color(&info->bg, argv[2]))
		return ERROR_UNKNOWN_COLOR;

	info->attr = 0;
	while (argc-- > 3) {
		int attr;

		if (!set_attribute(&attr, argv[argc]))
			return ERROR_UNKNOWN_ATTRIBUTE;
		info->attr |= attr;
	}

	return SUCCESS;
}
Пример #23
0
struct Shape * shape_rb_to_shape(VALUE shape_rb)
{
  if (TYPE(shape_rb) != T_HASH) rb_raise(rb_eArgError, "rb_shape_to_shape() expects a Hash");
  
  struct Shape * shape = new_shape();
  VALUE v;
  
  v = rb_hash_aref(shape_rb, ENCODED_STR_NEW2("unique_set_id", "ASCII-8BIT"));
  if (TYPE(v) != T_FIXNUM) rb_raise(rb_eArgError, "unique_set_id is not provided or is not a Fixnum");
  shape->unique_set_id = NUM2INT(v);
  
  v = rb_hash_aref(shape_rb, ENCODED_STR_NEW2("version", "ASCII-8BIT"));
  if (TYPE(v) != T_FIXNUM) rb_raise(rb_eArgError, "version is not provided or is not a Fixnum");
  shape->version = NUM2INT(v);
  
  v = rb_hash_aref(shape_rb, ENCODED_STR_NEW2("gl_type", "ASCII-8BIT"));
  if (TYPE(v) != T_FIXNUM) rb_raise(rb_eArgError, "gl_type is not provided or is not a Fixnum");
  shape->gl_type = NUM2INT(v);
  
  VALUE arrays = rb_hash_aref(shape_rb, ENCODED_STR_NEW2("vertex_arrays", "ASCII-8BIT"));
  if (TYPE(arrays) != T_HASH) rb_raise(rb_eArgError, "write_shape() expects a hash with a 'vertex_arrays' key containing a hash (was %d)", TYPE(arrays));
  rb_hash_foreach(arrays, foreach_array, (unsigned long)shape);
  
  VALUE attributes = rb_hash_aref(shape_rb, ENCODED_STR_NEW2("attributes", "ASCII-8BIT"));
  if (TYPE(attributes) != T_ARRAY) rb_raise(rb_eArgError, "write_shape() expects a hash with a 'attributes' key containing an array (was %d)", TYPE(attributes));
  int i;
  for (i = 0 ; i < RARRAY_LEN(attributes) ; i++)
  {
    VALUE v = rb_ary_entry(attributes, i);
    if (TYPE(v) != T_ARRAY) continue;
    
    char * name = RSTRING_PTR(rb_ary_entry(v, 0));
    char * value = RSTRING_PTR(rb_ary_entry(v, 1));
    set_attribute(shape, name, value);
  }
  
  return shape;
}
Пример #24
0
void frame::set_dim       (bool set) { set_attribute(set, A_DIM); }
Пример #25
0
void
DataNode::set_attribute(const tstring &name, Angle value)
{
  set_attribute(name, value.value_degrees());
}
Пример #26
0
void xmlt::set_attribute(
  const std::string &attribute,
  unsigned long long value)
{
  set_attribute(attribute, std::to_string(value));
}
int read_walk_distance_via_osm_to_bus_stop_from_iroquois(int argc, char ** argv, FILE * pipe_in, FILE * pipe_out, FILE * pipe_err)
{
  //char filename[300] = "";
  //int num_attributes = -1;
  //int c;
  //while ((c = getopt(argc, argv, "f:a:")) != -1)
  //switch (c)
  //{
  //  case 'f':
  //    strncpy(filename, optarg, 300);
  //    break;
  //  case 'a':
  //    num_attributes = atoi(optarg);
  //    break;
  //  default:
  //    abort();
  //}
  
  
  CURL *curl = NULL;
  CURLcode res;
  struct MemoryStruct chunk;
  
  char url[400];
  
  curl = curl_easy_init();
  
  struct Shape * shape = NULL;
  while ((shape = read_shape(pipe_in))) // address points
  {
    if (shape->num_vertexs > 1) { fprintf(stderr, "This is likely not the data this script was expecting. (was expecting addres points, single vertex shapes)\n"); break; }
    
    float * v = get_vertex(shape, 0, 0);
    
    chunk.memory = NULL;
    chunk.size = 0;
    
    sprintf(url, "http://localhost:3333/walk_distance_to_a_bus_stop?from=%f,%f", v[1], v[0]);
    
    curl_easy_setopt(curl, CURLOPT_URL, url);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
    curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
    res = curl_easy_perform(curl);
    
    if (chunk.size == 0)
    {
      set_attribute(shape, "route_error", "can not find a bus stop");
    }
    else
    {
      char * walk_distance = strtok(chunk.memory, ",");
      char * myttc_stop_id = strtok(NULL, ",");
      char * myttc_stop_name = strtok(NULL, ",");
      if (walk_distance != NULL) set_attribute(shape, "walk_distance", walk_distance);
      if (myttc_stop_id != NULL) set_attribute(shape, "myttc_stop_id", myttc_stop_id);
      if (myttc_stop_name != NULL) set_attribute(shape, "myttc_stop_name", myttc_stop_name);
    }
    
    free(chunk.memory);
    
    // manipulate data here if you like
    write_shape(pipe_out, shape);
    free_shape(shape);
  }
}
Пример #28
0
void frame::set_colour(const colour_pair& cp) { set_attribute(true, cp.get_id()); }
Пример #29
0
void frame::set_bold      (bool set) { set_attribute(set, A_BOLD); }
Пример #30
0
void frame::set_blinking  (bool set) { set_attribute(set, A_BLINK); }