MCPcopy Create free account
hub / github.com/apache/arrow / FormatStringParser

Class FormatStringParser

cpp/src/arrow/c/bridge.cc:847–938  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

845}
846
847class FormatStringParser {
848 public:
849 FormatStringParser() = default;
850
851 explicit FormatStringParser(std::string_view v) : view_(v), index_(0) {}
852
853 bool AtEnd() const { return index_ >= view_.length(); }
854
855 char Next() { return view_[index_++]; }
856
857 std::string_view Rest() { return view_.substr(index_); }
858
859 Status CheckNext(char c) {
860 if (AtEnd() || Next() != c) {
861 return Invalid();
862 }
863 return Status::OK();
864 }
865
866 Status CheckHasNext() {
867 if (AtEnd()) {
868 return Invalid();
869 }
870 return Status::OK();
871 }
872
873 Status CheckAtEnd() {
874 if (!AtEnd()) {
875 return Invalid();
876 }
877 return Status::OK();
878 }
879
880 template <typename IntType = int32_t>
881 Result<IntType> ParseInt(std::string_view v) {
882 using ArrowIntType = typename CTypeTraits<IntType>::ArrowType;
883 IntType value;
884 if (!internal::ParseValue<ArrowIntType>(v.data(), v.size(), &value)) {
885 return Invalid();
886 }
887 return value;
888 }
889
890 Result<TimeUnit::type> ParseTimeUnit() {
891 RETURN_NOT_OK(CheckHasNext());
892 switch (Next()) {
893 case 's':
894 return TimeUnit::SECOND;
895 case 'm':
896 return TimeUnit::MILLI;
897 case 'u':
898 return TimeUnit::MICRO;
899 case 'n':
900 return TimeUnit::NANO;
901 default:
902 return Invalid();
903 }
904 }

Callers 1

ProcessFormatMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected