Hippy项目源码分析(三)

2021SC@SDUSC

首篇文章已说明我的分工:Core全部内容

目录

  include\core\base\thread_id.h

 include\core\base\uri_loader.h

  include\core\base\thread_id.h

#pragma once

#include <pthread.h>
#include <stdint.h>

namespace hippy {
namespace base {

class ThreadId {
 public:
  constexpr ThreadId() noexcept = default;
  ~ThreadId();

  bool operator==(const ThreadId& other) const { return id_ == other.id_; }
  bool operator!=(const ThreadId& other) const { return id_ != other.id_; }

  void InitId(pthread_t id);
  static ThreadId GetCurrent();

 private:
  pthread_t id_ = kInvalidId;
  static pthread_t kInvalidId;
};

}  // namespace base
}  // namespace hippy

线程ID

 include\core\base\uri_loader.h

#pragma once

#include <memory>
#include <string>
#include <vector>

#include "base/unicode_string_view.h"

namespace hippy {
namespace base {

class UriLoader {
 public:
  using unicode_string_view = tdf::base::unicode_string_view;
  using u8string = unicode_string_view::u8string;

  UriLoader() {}
  virtual ~UriLoader() {}

  virtual bool RequestUntrustedContent(const unicode_string_view& uri,
                                       std::function<void(u8string)> cb) = 0;

  virtual bool RequestUntrustedContent(
      const unicode_string_view& uri,
      u8string& content) = 0;
};
}  // namespace base
}  // namespace hippy

 URI:统一资源标志符(Uniform Resource Identifier)  URL是可以直接操作的,但是URI并不行

URI组件

该类是不可变类(Instances of this class are immutable),提供了用于从其组成部分或通过解析其字符串形式创建 URI 实例的构造方法、用于访问实例的各个不同组成部分的方法,以及用于对 URI 实例进行规范化、解析和相对化的方法。

在java的uri类中,将URI字符串分为绝对RUI和相对URI,或者不透明URI(opaque uri)和分层URI(hierarchical uri)。其中,不透明 URI 为绝对 URI,且不透明的URI无法解析,例如:mailto:java-net@java.sun.com 、news:comp.lang.java、urn:isbn:096139210x,而分层URI即可以为绝对URI,也可以是相对URI,例如http://java.sun.com/j2se/1.3/ 是绝对URI,而../../../demo/jfc/SwingSet2/src/SwingSet2.java是相对URI。

分层URI
其结构为:[ scheme :][ // authority][ path][ ? query][ # fragment]
scheme与fragment部分是授权组成部分,可以基于服务,也可以基于注册表,常见的是基于服务,格式为:[ user-info @] host[ : port]
在给定实例中,任何特殊组成部分都或者为未定义的,或者为已定义的,并且有不同的值。未定义的字符串组成部分由 null 表示,未定义的整数组成部分由 -1 表示。
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值