Beispiel #1
0
void Phrase::CreateFromString(const std::vector<FactorType> &factorOrder
															, const string &phraseString
															, const string &factorDelimiter)
{
	vector< vector<string> > phraseVector = Parse(phraseString, factorOrder, factorDelimiter);
	CreateFromString(factorOrder, phraseVector);
}
Beispiel #2
0
char *  OOCEnv ::
DeSerialize(char  * buffer){
        unsigned int i;

	char * ptr = buffer;
	memcpy(&params,ptr,sizeof(Params) );ptr+=sizeof(Params) ;

        unsigned int n_binders  = *(unsigned int*)ptr; ptr+=sizeof(unsigned int);
        for(i = 0; i < n_binders; ++i) {
            NameUnknownTypeBind tb;
            ptr  =  tb.DeSerialize(ptr);
			AddNameUnknownTypeBound(tb);
        }

	int n_chain;
	memcpy(&n_chain,ptr,sizeof(int));ptr+=sizeof(int);

	std::string key,type;
	std::pair<ChainIterator,bool> ins;

	unsigned int mem; 
	for( int ic = 0; ic <n_chain;++ic){
		MemDbg::SetPoint(0);
		char * ptrB = ptr;																			// the pointer is saved in ptrB and then passed to DeSerialize
		ptr = ::DeSerialize(ptr,key);																// This is done to read "name" and "type" an to be able to create a chain
		ptr = ::DeSerialize(ptr,type);
		ins = chains.insert(std::pair<std::string,ChainBase*>(key,CreateFromString(key,type)));		// here the chain is allocated
		ptr = (*(ins.first)).second->DeSerialize(ptrB);												// Here DeSerialize with the saved poiner is called
		mem = MemDbg::MemFromPoint(0);
	}

	return ptr;
}
TargetPhrase::TargetPhrase(FactorDirection direction, std::string out_string)
  :Phrase(direction, 0),m_transScore(0.0), m_fullScore(0.0), m_sourcePhrase(0)
  , m_alignmentInfo(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
{

  //ACAT
  const StaticData &staticData = StaticData::Instance();
  CreateFromString(staticData.GetInputFactorOrder(), out_string, staticData.GetFactorDelimiter());
}
Beispiel #4
0
bool CComplexDateTime::CreateFromString (const CString &sString, CDatum *retdDatum)

//	CreateFromString
//
//	Creates a datum from a string

	{
	CDateTime DateTime;
	if (!CreateFromString(sString, &DateTime))
		return false;

	*retdDatum = CDatum(DateTime);
	return true;
	}
TargetPhrase::TargetPhrase( std::string out_string)
  :Phrase(0)
  , m_fullScore(0.0)
  , m_futureScore(0.0)
  , m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
  , m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
  , m_lhsTarget(NULL)
  , m_ruleSource(NULL)
{

  //ACAT
  const StaticData &staticData = StaticData::Instance();
  CreateFromString(Output, staticData.GetInputFactorOrder(), out_string, staticData.GetFactorDelimiter(), NULL);
}
Beispiel #6
0
bool Type::Build(const CXType &cxType)
{
  bool result = true;

  auto arraySize = clang_getArraySize(cxType);
  m_ArraySize = arraySize > 0 ? static_cast<int>(arraySize) : 0;

  int numTemplateArgs = clang_Type_getNumTemplateArguments(cxType);

  for (int i = 0; i < numTemplateArgs; ++i)
  {
    CXType tempType = clang_Type_getTemplateArgumentAsType(cxType, static_cast<unsigned>(i));
    const char *tempTypeSpelling = clang_getCString(clang_getTypeSpelling(tempType));
    std::unique_ptr<Type> t = std::unique_ptr<Type>(CreateFromString(this, tempTypeSpelling));
    if (t->Build(tempType))
    {
      m_TemplateArgs.push_back(std::move(t));
    }
    else
      result = false;
  }

  return result;
}
//-------------------------------------------------------------------------------
// @ IvVertexShaderOGL::CreateDefault()
//-------------------------------------------------------------------------------
// Create a default shader
//-------------------------------------------------------------------------------
bool
IvVertexShaderOGL::CreateDefault( IvVertexFormat format )
{
    return CreateFromString(sDefaultVertexShader[format]);
}