Beispiel #1
0
attribute attribute_find ( relation rel, char *name) {
/* attribute_find
 * Locates the given attribute, and returns an attribute structure
 */
	attribute catt,ratt;
	tuple ctuple;
	word anum;

	/* Get the first attribute */
	/* catt=attribute_findfirst(rel,&attribute_file); */
	catt=relation_attribute_readfirst(rel,&ctuple,&anum);

	/* Whilst the attribute is valid, and the attribute does
	 * not match the search criteria 
	 */
	while ( (catt!=NULL) && (name!=NULL) && (strcmp(attribute_name(catt),name)!=0) ) {

		/* Locate the next field */
		catt=relation_attribute_readnext(rel,&ctuple,catt,&anum);
	}

	/* Check to see if we actually found anything */
	if ( (catt!=NULL) && (name!=NULL) && (strcmp(attribute_name(catt),name)==0) ) {
	
		/* We're about to destroy the tuple, which will destroy the attribute
		 * we just found. Make a copy quick!
		 */
		/* Create a ptr to an attribute structure */
		ratt=(attribute_struct *) malloc(sizeof(attribute_struct));
	
		/* Check that the ptr was allocated. */
		check_assign(ratt,"attributes.attribute_find(cpy)");

		strcpy(attribute_name(ratt),attribute_name(catt));
		attribute_type(ratt)=attribute_type(catt);
		attribute_size(ratt)=attribute_size(catt);
		attribute_no(ratt)=attribute_no(catt);
		
		close_tuple(&ctuple,TUPLE_DISPOSE);

		/* Return the ptr */
		return(ratt);
	} else {
	
		/* Close the tuple */
		close_tuple(&ctuple,TUPLE_DISPOSE);

		/* Return nothing */	
		return(NULL);
	}
}
Beispiel #2
0
void sax_parser<_Handler,_Config>::attribute()
{
    sax::parser_attribute attr;
    pstring attr_ns_name, attr_name, attr_value;
    attribute_name(attr.ns, attr.name);

#if ORCUS_DEBUG_SAX_PARSER
    std::ostringstream os;
    os << "sax_parser::attribute: ns='" << attr.ns << "', name='" << attr.name << "'";
#endif

    char c = cur_char();
    if (c != '=')
    {
        std::ostringstream os;
        os << "Attribute must begin with 'name=..'. (ns='" << attr.ns << "', name='" << attr.name << "')";
        throw sax::malformed_xml_error(os.str());
    }

    next_check();
    attr.transient = value(attr.value, true);
    if (attr.transient)
        // Value is stored in a temporary buffer. Push a new buffer.
        inc_buffer_pos();

#if ORCUS_DEBUG_SAX_PARSER
    os << " value='" << attr.value << "'" << endl;
    cout << os.str();
#endif

    m_handler.attribute(attr);
}
Beispiel #3
0
Shader::Shader(
      const std::string& name,
      const std::vector<Attribute>& attributes,
      const std::vector<Uniform>& uniforms) :
   gl_shader_(GLShader::compileAndLinkShader(kShaderPath + name + ".vert", kShaderPath + name + ".frag")),
   program_name_(name)
{
#ifdef SHADER_WARN
   std::clog << "Successfully compiled/linked shader: "
      << name
      << " as program: "
      << gl_shader_.program()
      << std::endl;
#endif
   for (const auto& attr : attributes) {
      attribute_locations_.insert(std::make_pair(
               attr,
               gl_shader_.getAttributeLocation(attribute_name(attr))));
   }
   for (const auto& uniform : uniforms) {
      uniform_locations_.insert(std::make_pair(
               uniform,
               gl_shader_.getUniformLocation(uniform_name(uniform))));
   }
}
Beispiel #4
0
void attributes_print(relation rel) {
/* attribute_print
 * Print out all of the attributes associated with
 * a relation - For rl_display mainly.
 */
	attribute att;
	char fmt[FORMAT_SIZE];
	int counter;
	tuple ctuple;
	word count;

	att=relation_attribute_readfirst(rel,&ctuple,&count);
	/* Locate the first attribute */
	/* att=attribute_findfirst(rel,&attribute_file); */

	/* Move through the attributes */
	while (att!=NULL) {
		fmt_build(fmt,att);
		/* Display the first attribute */
		leap_printf(fmt,attribute_name(att));
		
		/* Locate the next attribute */
	/*	att=attribute_findnext(att,&attribute_file,FALSE,TRUE);	 */
		att=relation_attribute_readnext(rel,&ctuple,att,&count);
	}
	leap_printf("\n");
   /* Set to 79 for MS-DOS display wrapping... */
	for (counter=0;counter<79;counter++) leap_printf("-");
	leap_printf("\n");
}
Beispiel #5
0
bool LLXUIParser::readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block)
{
	typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
	boost::char_separator<char> sep(".");

	bool any_parsed = false;

	for(LLXMLAttribList::const_iterator attribute_it = nodep->mAttributes.begin(); 
		attribute_it != nodep->mAttributes.end(); 
		++attribute_it)
	{
		S32 num_tokens_pushed = 0;
		std::string attribute_name(attribute_it->first->mString);
		mCurReadNode = attribute_it->second;

		tokenizer name_tokens(attribute_name, sep);
		// copy remaining tokens on to our running token list
		for(tokenizer::iterator token_to_push = name_tokens.begin(); token_to_push != name_tokens.end(); ++token_to_push)
		{
			mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration()));
			num_tokens_pushed++;
		}

		// child nodes are not necessarily valid attributes, so don't complain once we've recursed
		bool silent = mCurReadDepth > 0;
		any_parsed |= block.submitValue(mNameStack, *this, silent);
		
		while(num_tokens_pushed-- > 0)
		{
			mNameStack.pop_back();
		}
	}

	return any_parsed;
}
Beispiel #6
0
boost::optional<std::pair<GLShaderHandle, GLAttributeLocation>> Shader::attributeLocation(
      const Attribute& attribute) {
   if (attribute_locations_.count(attribute) == 0) {
#ifdef SHADER_WARN
      std::clog << "Could not find attribute: " << attribute_name(attribute) <<
         " in shader program: " << program_name_ << std::endl;
#endif
      return boost::none;
   }
   return std::make_pair(
         gl_shader_.program(),
         attribute_locations_.at(attribute));
}
Beispiel #7
0
    //! Returns the attribute value.
    T value(const char *in_attribute_name) const
    {
      std::string attribute_name(in_attribute_name);
      auto it = this->_attributes.find(attribute_name);
      if (it == this->_attributes.end())
	{
	  std::cout << "ERROR: ChangeEvent::status, attribute \"" << attribute_name <<
	    "\" does not exist." << std::endl;
	  // TODO (throw an exception)
	  return T();
	}
      return (*it).second;
    }
Beispiel #8
0
    //! Switching the value of the attribute with name specified in first input argument.
    bool switching(const char *in_attribute_name, const T in_attribute_value)
    {
      std::string attribute_name(in_attribute_name);
      auto it = this->_attributes.find(attribute_name);
      if (it != this->_attributes.end())
	{
	  (*it).second = in_attribute_value;
	  return true;
	}
      else
	{
	  std::cout << "ERROR: ChangeEvent::switching, attribute \"" << attribute_name <<
	    "\" not found." << std::endl;
	  return false;
	}
    }
Beispiel #9
0
//rebuild_enum
void Ocio_test::rebuild_input_colorspace(int& change_list_index, MDataBlock& data)
{
	//config
	OCIO::ConstConfigRcPtr config;
	config = OCIO_functionality::get_config_from_env();


	//config_colorspaces
	std::vector<std::string> config_colorspaces = OCIO_functionality::get_colorspace_names(config);
	if (!config_colorspaces.size())
	{
		//tmp
		MGlobal::displayInfo("Config colorspaces empty. Returning None");
		return;
	};
	
	//node
	MObject node = thisMObject();
	
	//value_list
	std::string attribute_name("input_colorspace");


	//update_enum_attribute
	//remove attribute
	remove_attribute(node, attribute_name);

	//create_enum_attribute
	create_enum_attribute(attribute_name, 
							config_colorspaces,
							node);
	


	//Set last change index
	data.outputValue(a_last_change_index).setInt(change_list_index);
	//format
	boost::format change_index_msg("Last change index set to: %s");
	change_index_msg % change_list_index;
	MGlobal::displayInfo(change_index_msg.str().c_str());
	
};
Beispiel #10
0
void attribute_print(attribute att) {
/* attribute_print
 * Print out the information contained in the specified
 * attribute
 */
	char fmt[FORMAT_SIZE];

	fmt_build(fmt,att);

	/* Check that the ptr is assigned! */
	if (att!=NULL) {
		switch (attribute_type(att)) {
			case DT_STRING:
				leap_printf(DTS_STRING);
				leap_printf("      ");
				break;
			case DT_NUMBER:
				leap_printf(DTS_NUMBER);
				leap_printf("     ");
				break;
			case DT_BOOLEAN:
				leap_printf(DTS_BOOLEAN);
				leap_printf("     ");
				break;
			default:
				leap_printf(DTS_UNSUPPORTED);
				leap_printf(" ");
		}
		if (attribute_size(att)==0) leap_printf("-");
		else leap_printf("%d",attribute_size(att));

		if (attribute_size(att)<9) leap_printf("   ");
		else if (attribute_size(att)<99) leap_printf("  ");
		else leap_printf(" ");

		leap_printf("%-25.25s \n",attribute_name(att));
	}
}
Beispiel #11
0
//postConstructor
//-----------------------------------------------
void Ocio_test::postConstructor()
{
	//node
	MObject node = thisMObject();

	//value_list
	std::string attribute_name("input_colorspace");

	//value_list
	std::vector<std::string> value_list;
	value_list.push_back("HansPeter");
	value_list.push_back("Simon");
	value_list.push_back("Siggi");

	//create_enum_attribute
	create_enum_attribute(attribute_name, 
							value_list, 
							node);

	//emit test signal
	sig_postconstructor.connect(*boost_signal_helloworld);
	sig_postconstructor();

};