コード例 #1
0
ファイル: program.cpp プロジェクト: diybio/NinjaPCR
ProgramComponent* CommandParser::ParseCycle(char* pBuffer) {
  char countBuf[5];
	
  //find first step
  char* pStep = strchr(pBuffer, '[');
	
  //get cycle count
  int countLen = pStep - pBuffer;
  strncpy(countBuf, pBuffer, countLen);
  countBuf[countLen] = '\0';
  int cycCount = atoi(countBuf);
  
  Cycle* pCycle = gpThermocycler->GetCyclePool().AllocateComponent();
  pCycle->SetNumCycles(cycCount);
	
  //add steps
  while (pStep != NULL) {
    *pStep++ = '\0';
    char* pStepEnd = strchr(pStep, ']');
    *pStepEnd++ = '\0';

    Step* pNewStep = ParseStep(pStep);
    pCycle->AddComponent(pNewStep);
    pStep = strchr(pStepEnd, '[');
  }

  return pCycle;
}
コード例 #2
0
ファイル: program.cpp プロジェクト: diybio/NinjaPCR
Cycle* CommandParser::ParseProgram(char* pBuffer) {
  Cycle* pProgram = gpThermocycler->GetCyclePool().AllocateComponent();
  pProgram->SetNumCycles(1);
	
  char* pCycBuf = strtok(pBuffer, "()");
  while (pCycBuf != NULL) {
    pProgram->AddComponent(ParseCycle(pCycBuf));
    pCycBuf = strtok(NULL, "()");
  }
  
  return pProgram;
}