File tree Expand file tree Collapse file tree 3 files changed +197
-87
lines changed Expand file tree Collapse file tree 3 files changed +197
-87
lines changed Original file line number Diff line number Diff line change @@ -619,6 +619,16 @@ class Str {
619
619
return result;
620
620
}
621
621
622
+ // / Converts the string to a double
623
+ double toDouble () {
624
+ double result = 0 ;
625
+ char *eptr;
626
+ if (!isEmpty ()){
627
+ result = strtod (chars, &eptr);
628
+ }
629
+ return result;
630
+ }
631
+
622
632
// / Converts the string to lowercase letters
623
633
void toLowerCase (){
624
634
if (chars!=nullptr ){
@@ -654,6 +664,85 @@ class Str {
654
664
return result;
655
665
}
656
666
667
+ bool containsNumber () {
668
+ for (int j=0 ;j<len;j++){
669
+ if (isdigit (chars[j])){
670
+ return true ;
671
+ }
672
+ }
673
+ return false ;
674
+ }
675
+
676
+ // / Returns true if the string is an integer
677
+ bool isInteger () {
678
+ bool result = containsNumber ();
679
+ int dot_count = 0 ;
680
+ int minus_count = 0 ;
681
+ for (int j=0 ;j<len;j++){
682
+ char c = chars[j];
683
+ if (!isdigit (c)){
684
+ switch (c){
685
+ case ' -' :
686
+ minus_count++;
687
+ if (minus_count>1 ){
688
+ result = false ;
689
+ }
690
+ break ;
691
+ default :
692
+ result = false ;
693
+ break ;
694
+ }
695
+ }
696
+ }
697
+ return result;
698
+ }
699
+
700
+ // / Determines the number of decimals in the number string
701
+ int numberOfDecimals () {
702
+ int result = 0 ;
703
+ int pos = indexOf (" ." );
704
+ if (pos>=0 ){
705
+ for (int j=pos+1 ;j<len;j++){
706
+ if (isdigit (chars[j])){
707
+ pos++;
708
+ } else {
709
+ break ;
710
+ }
711
+ }
712
+ }
713
+ return result;
714
+ }
715
+
716
+ // Returns true if the string is a number
717
+ bool isNumber () {
718
+ bool result = containsNumber ();
719
+ int dot_count = 0 ;
720
+ int minus_count = 0 ;
721
+ for (int j=0 ;j<len;j++){
722
+ char c = chars[j];
723
+ if (!isdigit (c)){
724
+ switch (c){
725
+ case ' -' :
726
+ minus_count++;
727
+ if (minus_count>1 ){
728
+ result = false ;
729
+ }
730
+ break ;
731
+ case ' .' :
732
+ dot_count++;
733
+ if (dot_count>1 ){
734
+ result = false ;
735
+ }
736
+ break ;
737
+ default :
738
+ result = false ;
739
+ break ;
740
+ }
741
+ }
742
+ }
743
+ return result;
744
+ }
745
+
657
746
protected:
658
747
char * chars = nullptr ;
659
748
bool is_const=false ;
Original file line number Diff line number Diff line change @@ -244,6 +244,7 @@ class AudioKitStream : public AudioStreamX {
244
244
// / Update the audio info with new values: e.g. new sample_rate,
245
245
// / bits_per_samples or channels
246
246
virtual void setAudioInfo (AudioBaseInfo info) {
247
+ LOGI (LOG_METHOD);
247
248
cfg.sample_rate = info.sample_rate ;
248
249
cfg.bits_per_sample = info.bits_per_sample ;
249
250
cfg.channels = info.channels ;
You can’t perform that action at this time.
0 commit comments