[Groonga-commit] groonga/grnxx at 75b857e [master] Remove Name.

Zurück zum Archiv-Index

susumu.yata null+****@clear*****
Tue Dec 16 10:42:00 JST 2014


susumu.yata	2014-11-06 23:46:26 +0900 (Thu, 06 Nov 2014)

  New Revision: 75b857eb85df8b6d0763e8995d23fa97b6ad4098
  https://github.com/groonga/grnxx/commit/75b857eb85df8b6d0763e8995d23fa97b6ad4098

  Message:
    Remove Name.

  Removed files:
    lib/grnxx/name.cpp
    lib/grnxx/name.hpp
  Modified files:
    lib/grnxx/Makefile.am

  Modified: lib/grnxx/Makefile.am (+0 -2)
===================================================================
--- lib/grnxx/Makefile.am    2014-11-06 23:42:36 +0900 (571f477)
+++ lib/grnxx/Makefile.am    2014-11-06 23:46:26 +0900 (c0d825e)
@@ -17,7 +17,6 @@ libgrnxx_la_SOURCES =			\
 #	expression.cpp			\
 #	index.cpp			\
 #	merger.cpp			\
-#	name.cpp			\
 #	pipeline.cpp			\
 #	sorter.cpp
 
@@ -25,7 +24,6 @@ libgrnxx_includedir = ${includedir}/grnxx
 libgrnxx_include_HEADERS =		\
 	version.h
 
-#	name.hpp			\
 #	tree_index.hpp
 
 EXTRA_DIST = version.sh

  Deleted: lib/grnxx/name.cpp (+0 -50) 100644
===================================================================
--- lib/grnxx/name.cpp    2014-11-06 23:42:36 +0900 (dd3f9f1)
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "grnxx/name.hpp"
-
-namespace grnxx {
-namespace {
-
-bool is_alpha(int c) {
-  return ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'));
-}
-
-bool is_digit(int c) {
-  return (c >= '0') && (c <= '9');
-}
-
-bool is_allowed_symbol(int c) {
-  return c == '_';
-}
-
-}  // namespace
-
-bool Name::assign(Error *error, const StringCRef &name) {
-  if (!test(error, name)) {
-    return false;
-  }
-  return string_.assign(error, name);
-}
-
-bool Name::test(Error *error, const StringCRef &name) {
-  if ((name.size() < MIN_SIZE) || (name.size() > MAX_SIZE)) {
-    GRNXX_ERROR_SET(error, INVALID_NAME,
-                    "Invalid name size: size = %" PRIi64, name.size());
-    return false;
-  }
-  if (!is_alpha(name[0]) && !is_digit(name[0])) {
-    GRNXX_ERROR_SET(error, INVALID_NAME,
-                    "Name must start with an alphanumeric character");
-    return false;
-  }
-  for (Int i = 1; i < name.size(); ++i) {
-    if (!is_alpha(name[i]) &&
-        !is_digit(name[i]) &&
-        !is_allowed_symbol(name[i])) {
-      GRNXX_ERROR_SET(error, INVALID_NAME,
-                      "Name contains invalid characters");
-      return false;
-    }
-  }
-  return true;
-}
-
-}  // namespace grnxx

  Deleted: lib/grnxx/name.hpp (+0 -56) 100644
===================================================================
--- lib/grnxx/name.hpp    2014-11-06 23:42:36 +0900 (fde9686)
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef GRNXX_NAME_HPP
-#define GRNXX_NAME_HPP
-
-#include "grnxx/types.hpp"
-
-namespace grnxx {
-
-class Name {
- public:
-  Name() : string_() {}
-
-  const char &operator[](Int i) const {
-    return string_[i];
-  }
-
-  const char *data() const {
-    return string_.data();
-  }
-  Int size() const {
-    return string_.size();
-  }
-
-  // Return a reference to the name string.
-  StringCRef ref() const {
-    return string_.ref();
-  }
-
-  // Assign a new name.
-  // Allocates memory and copies the given name to it.
-  // Then, terminates the copied name with a null character '\0'.
-  //
-  // A name string can contain alphabets (A-Za-z), digits (0-9), and
-  // underscores (_).
-  //
-  // Returns true on success.
-  // On failure, returns false and stores error information into "*error" if
-  // "error" != nullptr.
-  bool assign(Error *error, const StringCRef &name);
-
- private:
-  String string_;
-
-  static constexpr Int MIN_SIZE = 1;
-  static constexpr Int MAX_SIZE = 1023;
-
-  // Check if "name" is valid as an object name or not.
-  //
-  // Returns true if "name" is valid.
-  // Otherwise, returns false and stores error information into "*error" if
-  // "error" != nullptr.
-  static bool test(Error *error, const StringCRef &name);
-};
-
-}  // namespace grnxx
-
-#endif  // GRNXX_NAME_HPP
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index