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

Class FormatStringParser

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

Source from the content-addressed store, hash-verified

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

Callers 1

ProcessFormatMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected