Esempio n. 1
0
/**
 * Build a response text based on result from server method
 */
std::string Proto::build_response(Response& resp) {
  JObject* obj = new JObject();
  obj->put(Result, resp.get_serializer().getContent());

  std::string jsonText = dumps(obj);
  delete obj;
  return jsonText; 
}
Esempio n. 2
0
/**
 * Build an error message given error code
 */
std::string Proto::build_error(int code) {
  JObject* obj = new JObject();
  obj->put(Error, code);

  std::string jsonText = dumps(obj);
  delete obj;
  return jsonText;
}
Esempio n. 3
0
std::string Proto::build_request(
                     int clientno, int serverno,
                     int messageid, long timestamp,
                     size_t method_hash, OutSerializer& sout) {
  JObject* obj = new JObject();
  obj->put(ClientNo, clientno);
  obj->put(ServerNo, serverno);
  obj->put(Version, 1);
  obj->put(Timestamp, timestamp);
  obj->put(MessageId, messageid);
  obj->put(Method, method_hash);
  obj->put(Param, sout.getContent());

  std::string msg = dumps(obj);
  delete obj;
  return msg;
}
Esempio n. 4
0
void  init( void )
   {
    int i;

    /* fill twobits[] */
    bzero( twobit, N_ASCII * sizeof( unsigned int ) );
    for ( i = 0; i < 4; i++ )
         twobit[real_nts[i]] = twobit[real_nts[i]+LOWER_OFF] = i;
#ifdef DEBUG
    dumps( "twobit", twobit );
#endif

    /* fill no_count[] - don't count anything ...*/
    for ( i = 0; i < N_ASCII; i++ )
        no_count[i] = 1;
    /*... except real nucleotides */
    for ( i = 0; i < 4; i++ )
         no_count[real_nts[i]] = no_count[real_nts[i]+LOWER_OFF] = 0;
#ifdef DEBUG
    dumps( "no_count", no_count );
#endif

    /* is_not_space[c] is true for any chars which are not control  */
    /* chars or whitespace (make whitespace explicit here!)         */

    for ( i = 0; i < N_ASCII; i++ )
        if ( i >= 33 && i <= 126 && i != ' ' && i != '\t' && i != '\n' )
            is_not_space[i] = 1;
        else
            is_not_space[i] = 0;
#ifdef DEBUG
    dumps( "is_not_space", is_not_space );
#endif

    w_mask = 0;
    n_kmers = 1;
    for ( i = 0; i < word_size; i++ )
       {
        w_mask = (w_mask << 2) | 0x3;
        n_kmers *= 4;
       }

#ifdef DEBUG
    printf( "word_size is %d, w_mask is %x, n_kmers is %d (0x%x)\n", 
             word_size, w_mask, n_kmers, n_kmers );
#endif

    for ( i = 0; i < n_kmers; i++ )
       {
        kmer_seq[i] = strdup( int2seq( i ) );
#ifdef DEBUG
        printf( "%10d 0x%08x [%s]\n", i, i, kmer_seq[i] );
#endif
       }    
    for ( i = 0; i < n_kmers; i++ )
       {
        rc_map[i] = intcomp( i );
#ifdef DEBUG
        printf( "%10d 0x%08x [%s] -> %10d 0x%08x [%s]\n", 
            i, i, kmer_seq[i], rc_map[i], rc_map[i], kmer_seq[rc_map[i]] ); 
#endif
       }    
   }