示例#1
0
void non_required_module_is_not_visible()
{
    World* world = global_world();

    test_write_fake_file("module_a.ca", 1, "a = 1");
    test_write_fake_file("module_b.ca", 1, "b = 1");
    Block* module_a = load_module_file(world, temp_string("module_a"), "module_a.ca");
    Block* module_b = load_module_file(world, temp_string("module_b"), "module_b.ca");
    test_assert(find_name(module_a, "a") != NULL);
    test_assert(find_name(module_b, "a") == NULL);
}
示例#2
0
void source_file_location()
{
    test_write_fake_file("block.ca", 1, "a = 1");
    Block* block = load_module_file(global_world(),
        temp_string("source_file_location"), "block.ca");

    test_equals(block_get_source_filename(block), "block.ca");
}
示例#3
0
string FGPropertyManager::GetPrintableName( void )
{
  string temp_string(getName());
  size_t initial_location=0;
  size_t found_location;

  found_location = temp_string.rfind("/");
  if (found_location != string::npos)
  temp_string = temp_string.substr(found_location);

  found_location = temp_string.find('_',initial_location);
  while (found_location != string::npos) {
    temp_string.replace(found_location,1," ");
    initial_location = found_location+1;
    found_location = temp_string.find('_',initial_location);
  }
  return temp_string;
}
示例#4
0
文件: Parser.cpp 项目: Dyrand/DyrBot
 irc_privmsg_struct irc_privmsg(const irc_message_struct& message, const std::string& unique_delim)
 {
     irc_privmsg_struct privmsg_struct;

     auto delim = message.prefix.find("!~");
     privmsg_struct.nickname = message.prefix.substr(1,delim-1);

     auto at_symbol = message.prefix.find('@');
     privmsg_struct.username = message.prefix.substr(delim+2,(at_symbol-delim)-2);

     delim = message.parameters.find(' ');
     privmsg_struct.target = message.parameters.substr(0,delim);

     delim = message.parameters.find(':');
     auto unique_pos = message.parameters.find(unique_delim,delim+1);
     //Check if command identifier is just after ':'
     if(unique_pos == delim+1)
     {
         privmsg_struct.ident = unique_delim;
         
         while(unique_pos != std::string::npos)
         {
             //Parse command
             auto begin_pos = message.parameters.find_first_not_of(' ',unique_pos+unique_delim.length());
             delim = message.parameters.find(' ',begin_pos+1);
             
             //Command exists
             if(begin_pos != std::string::npos)
             { privmsg_struct.command.emplace_back(message.parameters.substr(begin_pos,delim-begin_pos)); }
             //Empty command
             else
             { 
                privmsg_struct.command.emplace_back("");
                privmsg_struct.after_command.emplace_back("");
                privmsg_struct.arguments.emplace_back(std::map<std::string,std::vector<std::string> >());
                break;
             }

             delim = message.parameters.find_first_not_of(' ',delim);

             //Parse after_command
             unique_pos = message.parameters.find(unique_delim,delim);
             
             while(unique_pos != std::string::npos && message.parameters.at(unique_pos-1) != ' ')
             { unique_pos = message.parameters.find(unique_delim,unique_pos+1); }

             if(unique_pos != std::string::npos)
             { privmsg_struct.after_command.emplace_back(message.parameters.substr(delim,unique_pos-delim)); }
             else if(delim != std::string::npos)
             { privmsg_struct.after_command.emplace_back(message.parameters.substr(delim,std::string::npos)); }
             else
             { privmsg_struct.after_command.emplace_back("");}

             //Parse command arguments
             std::string active_modifier;
             privmsg_struct.arguments.emplace_back(std::map<std::string,std::vector<std::string> >());
             while(delim != unique_pos && delim != std::string::npos)
             {
                 auto end_pos = message.parameters.find(' ',delim);

                 std::string temp_string(message.parameters.substr(delim,end_pos-delim));
                 if(temp_string.front() == '-')
                 {
                     privmsg_struct.arguments.back()[temp_string] = std::vector<std::string>();
                     active_modifier = temp_string;
                 }
                 else
                 { privmsg_struct.arguments.back()[active_modifier].emplace_back(std::move(temp_string)); }

                 delim = message.parameters.find_first_not_of(' ',end_pos);
             }
         }
     }
        
     return privmsg_struct;
 }
	void isis_ProMdlRetrieve_WithDescriptiveErrorMsg( 
										   // Added Arguments
										  const std::string &in_ComponentID,
										  const std::string &in_Model_Name,
										  const isis::MultiFormatString &in_Representation,
										  // Original arguments
										  const ProFamilyName name, 
										  ProMdlType    type,
										  ProMdl       *p_handle)
										  throw (isis::application_exception)
	{

		log4cpp::Category& logcat_fileonly = log4cpp::Category::getInstance(LOGCAT_LOGFILEONLY);
		log4cpp::Category& logcat_consoleandfile = log4cpp::Category::getInstance(LOGCAT_CONSOLEANDLOGFILE);
		try
		{

			if ( in_Representation.size() > 0 )
			{

				// Retreive the whole assembly.  This is a workaround because bounding box does not 
				// compute properly if a simplified rep leaves out .prts/.asms from memory.
				// Pull everything into memory, and then load the simplified rep models.
				// If this is done then the STEP file would contain all the geometry isis::isis_ProMdlRetrieve(name,type, p_handle);	

				// try to retrieve the simplified rep
				if ( type == PRO_MDL_ASSEMBLY )
				{
					ProError err;
						
					if ( isis::ConvertToUpperCase(in_Representation) ==  "DEFAULT ENVELOPE REP")
					{

						err = ProDefaultEnvelopeSimprepRetrieve( (wchar_t*)name, (ProAssembly *)p_handle );
					
						//std::cout << std::endl << std::endl <<	">>>> Assembly: " << std::endl  << 
						//											"   Model  Name:                       " << in_Model_Name << std::endl  << 
						//											"   Representation:                    " << in_Representation << std::endl  << 
						//											"   ProAssemblySimprepRetrieve, Error: " << err;

						if (  err == PRO_TK_BAD_INPUTS )
						{
							std::stringstream errorString;
							errorString 
							<<	"Function - isis_ProMdlRetrieve_WithDescriptiveErrorMsg, ProAssemblySimprepRetrieve received erroneous inputs: " << std::endl <<
								"   ComponentInstanceID: " <<  in_ComponentID << std::endl <<
								"   Model Name:          " <<  in_Model_Name  << std::endl <<
								"   Model Handle:         " << p_handle << std::endl <<
								"   Representation:      " <<  in_Representation<< std::endl;  
							throw isis::application_exception(errorString);

						}

					}
					else
					{

						err = ProAssemblySimprepRetrieve( (wchar_t*)name, (wchar_t*)(const wchar_t*) in_Representation, NULL, (ProAssembly *)p_handle );
					
						isis::MultiFormatString temp_string(name);
						//std::cout << std::endl << std::endl <<	">>>>>>>>>>>> Assembly: " << std::endl  << 
						//											"   Model  Name:                       " << in_Model_Name << std::endl  << 
						//											"   Representation:                    " << in_Representation << std::endl  << 
						//											"   Representation Name:               " << (char *)(const char *)temp_string << std::endl  << 
						//											"   ProAssemblySimprepRetrieve, Error: " << err << std::endl <<
						//											"<<<<<<<<<<<<<<<<<<";


						if (  err == PRO_TK_BAD_INPUTS )
						{
							std::stringstream errorString;
							errorString 
							<<	"Function - isis_ProMdlRetrieve_WithDescriptiveErrorMsg, ProAssemblySimprepRetrieve received erroneous inputs: " << std::endl <<
								"   ComponentInstanceID: " <<  in_ComponentID << std::endl <<
								"   Model Name:          " <<  in_Model_Name  << std::endl <<
								"   Model Handle:         " << p_handle << std::endl <<
								"   Representation:      " <<  in_Representation<< std::endl;  
							throw isis::application_exception(errorString);

						}

						
						//ProError proError_temp;
						//ProSimprep proSimprep_temp;


						//ProSimprepActiveGet ((ProSolid)*p_handle, 
                        //            &proSimprep_temp);

						//std::cout << std::endl << "##########################";
						//std::cout << std::endl << "proSimprep_temp.id: "  << proSimprep_temp.id;
						//std::cout << std::endl << "proSimprep_temp.owner: "  << proSimprep_temp.owner;
						//std::cout << std::endl << "roSimprep_temp.type: "  << proSimprep_temp.type;
						//std::cout << std::endl << "##########################";

						
						//proError_temp  = ProSimprepInit ((wchar_t*)(const wchar_t*) in_Representation,
						//								  -1,
						//								  (ProSolid)*p_handle,
						//								  &proSimprep_temp );
						//
						//std::cout << std::endl << std::endl << "ProSimprepInit, Error Code: " << proError_temp;
						//
						//ProSimprepActivate ((ProSolid)*p_handle, &proSimprep_temp);
						//std::cout << std::endl << std::endl << "ProSimprepActivate, Error Code: " << proError_temp << std::endl;
						//

					}



					if ( err == PRO_TK_NO_ERROR )   
					{
						// assembly was retrieved.
						logcat_fileonly.infoStream() << "Representation: " << in_Representation << ", was found for ComponentInstanceID: " << in_ComponentID << ", Model Name: " << in_Model_Name << ".";
						return; // model was retrieved. 
					}
					else
					{
						logcat_fileonly.warnStream() << "Representation: " << in_Representation << ", was NOT found for ComponentInstanceID: " << in_ComponentID << ", Model Name: " << in_Model_Name << ".  Using active representation.";
					}

				}
				else
				{  // PRO_MDL_PART

					ProError err; 
					
					if ( isis::ConvertToUpperCase(in_Representation) ==  "MASTER REP")
					{
						// This code seems to never set the "Master Rep".  Will leave it in at least
						// until the problem is understood.
						err = ProPartSimprepRetrieve ((wchar_t*)name, 
												PRO_SIMPREP_MASTER_REP,
												(wchar_t*)(const wchar_t*) in_Representation,
												(ProPart*)p_handle);


						//std::cout << std::endl << std::endl <<	">>>> Part: " << std::endl  << 
						//										"   Model  Name:                   " << in_Model_Name << std::endl  << 
						//										"   Representation:                " << in_Representation << std::endl  << 
						//										"   ProPartSimprepRetrieve, Error: " << err;

						if (  err == PRO_TK_BAD_INPUTS )
						{
							std::stringstream errorString;
							errorString 
							<<	"Function - isis_ProMdlRetrieve_WithDescriptiveErrorMsg, ProPartSimprepRetrieve received erroneous inputs: " << std::endl <<
								"   ComponentInstanceID: " <<  in_ComponentID << std::endl <<
								"   Model Name:          " <<  in_Model_Name  << std::endl <<
								"   Model Handle:         " << p_handle << std::endl <<
								"   Representation:      " <<  in_Representation<< std::endl;  
							throw isis::application_exception(errorString);

						}
					}
					else
					{
						err = ProPartSimprepRetrieve ((wchar_t*)name, 
												PRO_SIMPREP_USER_DEFINED,
												(wchar_t*)(const wchar_t*) in_Representation,
												(ProPart*)p_handle);

						//std::cout << std::endl << std::endl <<	">>>> Part: " << std::endl  << 
						//										"   Model  Name:                   " << in_Model_Name << std::endl  << 
						//										"   Representation:                " << in_Representation << std::endl  << 
						//										"   ProPartSimprepRetrieve, Error: " << err;

						if (  err == PRO_TK_BAD_INPUTS )
						{
							std::stringstream errorString;
							errorString 
							<<	"Function - isis_ProMdlRetrieve_WithDescriptiveErrorMsg, ProPartSimprepRetrieve received erroneous inputs: " << std::endl <<
								"   ComponentInstanceID: " <<  in_ComponentID << std::endl <<
								"   Model Name:          " <<  in_Model_Name  << std::endl <<
								"   Model Handle:         " << p_handle << std::endl <<
								"   Representation:      " <<  in_Representation<< std::endl;  
							throw isis::application_exception(errorString);

						}

					}
					

					if ( err == PRO_TK_NO_ERROR )
					{
						// Part retrieved
						logcat_fileonly.infoStream() << "Representation: " << in_Representation << ", was found for ComponentInstanceID: " << in_ComponentID << ", Model Name: " << in_Model_Name << ".";
						return; // model was retrieved. 
					}
					else
					{
						logcat_fileonly.warnStream() << "Representation: " << in_Representation << ", was NOT found for ComponentInstanceID: " << in_ComponentID << ", Model Name: " << in_Model_Name << ".  Using active representation.";
					}
				} // END Else if ( type == PRO_MDL_ASSEMBLY )

				

			}
			else
			{
				logcat_fileonly.infoStream() << "A Representation was not specified for ComponentInstanceID: " << in_ComponentID << ", Model Name: " << in_Model_Name << ".";
			} // END if ( in_Representation.size() > 0 )

			// If made it to here, then the simplified rep was not found.

			// Commented lines are for testing via setting the case
			//isis::MultiFormatString  name_multi(name);
			//std::string temp_Upper = ConvertToLowerCase(name_multi);	
			//isis::MultiFormatString  name_Upper_multi(temp_Upper);
			//std::cout << std::endl << "name size: " << name_multi.size();
			//isis::isis_ProMdlRetrieve(name_Upper_multi,type, p_handle);	

			isis::isis_ProMdlRetrieve(name,type, p_handle);	
		}
		catch ( isis::application_exception& ex )
		{
			try 
			{
				ProPath path; 
				isis_ProDirectoryCurrentGet( path );
				isis::MultiFormatString  path_MultiFormatString(path);
				logcat_consoleandfile.errorStream() << "ProDirectoryCurrent: " << path_MultiFormatString;
			}
			catch ( isis::application_exception ex)
			{
				logcat_consoleandfile.errorStream() << "Failed to retrieve ProDirectoryCurrent. Exception: " << ex.what(); 
			}

			//char modelName[ISIS_CHAR_BUFFER_LENGTH];
			//ProWstringToString(modelName, (char *)in_Model_Name.c_str());	

			std::stringstream errorString;
				errorString <<
						"exception : Failed to open a Creo Model:"  << std::endl <<
						"   Model Name:            " << in_Model_Name << std::endl <<
						"   Model Type:            " << isis::ProMdlType_string(type) <<  std::endl <<
						"   Component Instance ID: " << in_ComponentID << std::endl <<
						"   Exception Message:     " << ex.what();
			throw isis::application_exception("C05001",errorString.str().c_str());
		}

	}