stringtoint

danya/stringtonumber/stringtoint

No description
stringtoint
@/stringtoint
IN1string
IN2boolean
ignore point in string? : 1.57 - 157
stringtoint
OUT1
OUT2
OUT3
OUT4
IN1
IN2
OUT4number
OUT3number
OUT2number
OUT1number
To use the node in your project you should have the danya/stringtonumber library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

//#pragma XOD require "https://github.com/cocoz1/cpp-string"
//#include <string>

#include <string.h>


struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    //auto inValue = getValue<input_IN>(ctx);
    //emitValue<output_OUT>(ctx, inValue);
 
  
 auto xString = getValue<input_IN1>(ctx);
    bool dot = getValue<input_IN2>(ctx);
    int N = length(xString) + 1;
    int f = 0;
    int s = 0;
    int t = 0;
    int l = 0;
    Number ix = 0;
    Number i = 0;
    char x[N];
for(int i=0;i<N;i++)
x[i]=0;
dump(xString, x);
 
    char d[sizeof(x)];
    for(char* a=x, *b=d; *a; ++a, ++b, ++ix){
        while(*a=='.') ++a;
        *b=*a;
    }
  if (!dot){
      dump(xString, d);
  } else {
  if (atof(x) != floor(atof(x))){
    N = N-1;
  }
   }
    
    if(N==2){
        l = d[0];
    }
    if(N==3){
        l = d[1];
        t = d[0];
    }
    if(N==4){
        l = d[2];
        t = d[1];
        s = d[0];
    }
    if(N==5){
        l = d[3];
        t = d[2];
        s = d[1];
        f = d[0];
    }

     //if(f == 46){
         
    // }
    
        
    

emitValue<output_OUT1>(ctx, f);
emitValue<output_OUT2>(ctx, s);
emitValue<output_OUT3>(ctx, t);
emitValue<output_OUT4>(ctx, l);
}